From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 019F9A00C3; Wed, 2 Feb 2022 20:48:09 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE8C940E28; Wed, 2 Feb 2022 20:48:09 +0100 (CET) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by mails.dpdk.org (Postfix) with ESMTP id D31C140141 for ; Wed, 2 Feb 2022 20:48:08 +0100 (CET) Received: by mail-pg1-f177.google.com with SMTP id 132so386297pga.5 for ; Wed, 02 Feb 2022 11:48:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=B0W6zf6W8YNq+Vx515guq6J6Q6EH3mlCwMVQS8JQeqA=; b=swR0iFRO1A4jW/Toz4moPrObuj6IV55ooEziFpNB3JatW5/GA5x6T7EmOmNYUjSIvf EIRclydSqY64PvYu4Q+0oDTABnBkJTzHG/UnN8VTKbmexuT762+b6rDlZZELM2TVGKI+ fZnUOSZptEfD9Z8JLqu8YZ90mgDIsDgZ+X3V0aIb/E1CCAEd7t512AJyUoXE7MQjr2Yx AqAza1uVmFPFvOipQIhyZV/x5lZKnSUquFJnMSf6METXk0qphItylomCHAnTEoMlHgA5 Umm7kSYVW08bp2Yqf3gn1JmS+22Hkl7xVXypABBlt4L2weDQxbg3uPaKKsCVryREJLuZ vIJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=B0W6zf6W8YNq+Vx515guq6J6Q6EH3mlCwMVQS8JQeqA=; b=l+h5MnjyiqxkvOMVSDxRHtBnBMzMQV3t547JaN1FV9dwmK+CussI509YD9UhdkGG14 uK0I2+NevJQQmFJJOzsGu4HVL79P7qlOa98VRs0SYG1FheZlohb/XB7mIOxDH9HsMYr0 bPEhoWwjy1fa90kn3wrEeyXZl9TVU0ap9irsKUny9koG1Tu9Hm8rImtqzE+nO64yFHic fsfeGb4VH7iJT2dOvWA0gDh09Wz3bDhVIm/qXxBOO3cH3TVLkYAJFDU6ZkB2kfQ//Vtk 3y7Ossa7UWoSLFl5dzazoS/6IM/50TcefcDwmiKu8hNCSWZlatOSoXZM8ERKmkPcbMUm PqMg== X-Gm-Message-State: AOAM532BdRuw0yXahpxKPITwAFzdaZrv7RF68Oqo2DCaMy5wjjQNsd/e hxe+LNJKkAKzcegnArzgJqALSlNuyTiRigDh X-Google-Smtp-Source: ABdhPJznW1TWdK65Q67BIzLgzHzaLC6H5dEsiOJaxD/sXT3jGMbb6+TrnBXwQ5GxqH4p0QTv5icyFA== X-Received: by 2002:a63:618d:: with SMTP id v135mr1571286pgb.214.1643831287491; Wed, 02 Feb 2022 11:48:07 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id w4sm34458817pgs.28.2022.02.02.11.48.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Feb 2022 11:48:06 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Stephen Hemminger Subject: [PATCH] eal: remove unnecessary argv[0] handling Date: Wed, 2 Feb 2022 11:47:39 -0800 Message-Id: <20220202194738.404876-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The rte_eal_init function looks at argv[0] to determine the program name to pass to the log init function. This is both unnecessary and in a corner case a problem. Parsing argv[0] is unnecessary because the function openlog() already determines the log identifier from program name if NULL is passed, see openlog man page: The string pointed to by ident is prepended to every message, and is typically set to the program name. If ident is NULL, the program name is used. (POSIX.1-2008 does not specify the behavior when ident is NULL.) It is possible to run a program with argc=0 and argv[0]=NULL. This would cause rte_eal_init() to dereference a null pointer. Not a really useful feature, but better for DPDK get a SEGV if it doesn't need to. Signed-off-by: Stephen Hemminger --- lib/eal/linux/eal.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 60b49248388e..6bc7cdf440b8 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -966,8 +966,6 @@ rte_eal_init(int argc, char **argv) pthread_t thread_id; static uint32_t run_once; uint32_t has_run = 0; - const char *p; - static char logid[PATH_MAX]; char cpuset[RTE_CPU_AFFINITY_STR_LEN]; char thread_name[RTE_MAX_THREAD_NAME_LEN]; bool phys_addrs; @@ -989,8 +987,6 @@ rte_eal_init(int argc, char **argv) return -1; } - p = strrchr(argv[0], '/'); - strlcpy(logid, p ? p + 1 : argv[0], sizeof(logid)); thread_id = pthread_self(); eal_reset_internal_config(internal_conf); @@ -1165,7 +1161,7 @@ rte_eal_init(int argc, char **argv) #endif } - if (eal_log_init(logid, internal_conf->syslog_facility) < 0) { + if (eal_log_init(NULL, internal_conf->syslog_facility) < 0) { rte_eal_init_alert("Cannot init logging."); rte_errno = ENOMEM; __atomic_store_n(&run_once, 0, __ATOMIC_RELAXED); -- 2.34.1