From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 0B620959 for ; Tue, 16 Dec 2014 16:05:14 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 16 Dec 2014 07:01:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,691,1406617200"; d="scan'208";a="499566212" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga003.jf.intel.com with ESMTP; 16 Dec 2014 06:59:43 -0800 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id sBGF3s48008300; Tue, 16 Dec 2014 15:03:54 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id sBGF3rcc016844; Tue, 16 Dec 2014 15:03:53 GMT Received: (from bricha3@localhost) by sivswdev01.ir.intel.com with id sBGF3rdp016840; Tue, 16 Dec 2014 15:03:53 GMT From: Bruce Richardson To: dev@dpdk.org Date: Tue, 16 Dec 2014 15:03:52 +0000 Message-Id: <1418742233-16776-5-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1418742233-16776-1-git-send-email-bruce.richardson@intel.com> References: <1418742233-16776-1-git-send-email-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH 4/5] examples: fix check for null before de-reference X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Dec 2014 15:05:15 -0000 The check for NULL is in the wrong position in the "if" error leg. The pointer should be checked for NULL before checking what the value of what the pointer points to is. Signed-off-by: Bruce Richardson --- examples/vm_power_manager/channel_manager.c | 2 +- examples/vm_power_manager/vm_power_cli.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/vm_power_manager/channel_manager.c b/examples/vm_power_manager/channel_manager.c index 34a395d..04344ae 100644 --- a/examples/vm_power_manager/channel_manager.c +++ b/examples/vm_power_manager/channel_manager.c @@ -389,7 +389,7 @@ add_all_channels(const char *vm_name) errno = 0; channel_num = (unsigned)strtol(remaining, &tail_ptr, 0); if ((errno != 0) || (remaining[0] == '\0') || - (*tail_ptr != '\0') || tail_ptr == NULL) { + tail_ptr == NULL || (*tail_ptr != '\0')) { RTE_LOG(WARNING, CHANNEL_MANAGER, "Malformed channel name" "'%s' found it should be in the form of " "'.(decimal)'\n", diff --git a/examples/vm_power_manager/vm_power_cli.c b/examples/vm_power_manager/vm_power_cli.c index e7f4469..bd685fd 100644 --- a/examples/vm_power_manager/vm_power_cli.c +++ b/examples/vm_power_manager/vm_power_cli.c @@ -323,7 +323,7 @@ cmd_channels_op_parsed(void *parsed_result, struct cmdline *cl, break; errno = 0; channel_num = (unsigned)strtol(token, &tail_ptr, 10); - if ((errno != 0) || (*tail_ptr != '\0') || tail_ptr == NULL) + if ((errno != 0) || tail_ptr == NULL || (*tail_ptr != '\0')) break; if (channel_num == CHANNEL_CMDS_MAX_VM_CHANNELS) { @@ -408,7 +408,7 @@ cmd_channels_status_op_parsed(void *parsed_result, struct cmdline *cl, break; errno = 0; channel_num = (unsigned)strtol(token, &tail_ptr, 10); - if ((errno != 0) || (*tail_ptr != '\0') || tail_ptr == NULL) + if ((errno != 0) || tail_ptr == NULL || (*tail_ptr != '\0')) break; if (channel_num == CHANNEL_CMDS_MAX_VM_CHANNELS) { -- 1.9.3