From patchwork Tue Aug 9 20:12:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Dilger X-Patchwork-Id: 657466 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3s857h5cSRz9t0F for ; Wed, 10 Aug 2016 06:13:20 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752356AbcHIUNT (ORCPT ); Tue, 9 Aug 2016 16:13:19 -0400 Received: from mga04.intel.com ([192.55.52.120]:60773 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751590AbcHIUNS (ORCPT ); Tue, 9 Aug 2016 16:13:18 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP; 09 Aug 2016 13:13:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,496,1464678000"; d="scan'208";a="862548282" Received: from pmhollax-mobl3.amr.corp.intel.com ([10.254.106.165]) by orsmga003.jf.intel.com with ESMTP; 09 Aug 2016 13:13:17 -0700 From: Andreas Dilger To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org, Andreas Dilger Subject: [PATCH] fsck: fix strange logic Date: Tue, 9 Aug 2016 14:12:56 -0600 Message-Id: <1470773576-18604-1-git-send-email-andreas.dilger@intel.com> X-Mailer: git-send-email 2.4.5 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org llvm warns about the confusingly written comparison: !strncmp(argv[i+1], "-", 1) == 0) { misc/fsck.c:1178 col 9: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses] misc/fsck.c:1178 col 9: note: add parentheses after the '!' to evaluate the comparison first misc/fsck.c:1178 col 9: note: add parentheses around left hand side expression to silence this warning It makes sense to simplify this to a character comparison rather than using strncmp() to check only one character. Signed-off-by: Andreas Dilger --- misc/fsck.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/fsck.c b/misc/fsck.c index 826aaeb..4f918b7 100644 --- a/misc/fsck.c +++ b/misc/fsck.c @@ -1174,8 +1174,8 @@ static void PRS(int argc, char *argv[]) progress_fd = 0; else goto next_arg; - } else if ((i+1) < argc && - !strncmp(argv[i+1], "-", 1) == 0) { + } else if (argc > i + 1 && + argv[i + 1][0] == '-') { progress_fd = string_to_int(argv[i]); if (progress_fd < 0) progress_fd = 0;