From patchwork Fri Dec 19 06:13:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 5517531 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 80E61BEEA8 for ; Fri, 19 Dec 2014 06:15:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B27682012B for ; Fri, 19 Dec 2014 06:15:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D766920125 for ; Fri, 19 Dec 2014 06:15:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752037AbaLSGPU (ORCPT ); Fri, 19 Dec 2014 01:15:20 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:17798 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751913AbaLSGPR (ORCPT ); Fri, 19 Dec 2014 01:15:17 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="45493152" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 19 Dec 2014 14:11:54 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id sBJ6Ensb027643 for ; Fri, 19 Dec 2014 14:14:49 +0800 Received: from localhost.localdomain (10.167.226.33) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 19 Dec 2014 14:15:15 +0800 From: Qu Wenruo To: Subject: [PATCH 2/5] btrfs-progs: Fix a clang dead-judgement warning in disk-io.c. Date: Fri, 19 Dec 2014 14:13:09 +0800 Message-ID: <1418969592-21278-3-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1418969592-21278-1-git-send-email-quwenruo@cn.fujitsu.com> References: <1418969592-21278-1-git-send-email-quwenruo@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.33] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When compiled with clang, the following warning is outputted. disk-io.c:1017:15: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare] if (dev_size < 0) ~~~~~~~~ ^ ~ 1 warning generated. This is because dev_size is defined as unsigned type, but lseek() will return singed valued. So the judgement will always to false. Use temporary off_t return value to solve it. Signed-off-by: Qu Wenruo --- disk-io.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/disk-io.c b/disk-io.c index 03edf8e..2bf8586 100644 --- a/disk-io.c +++ b/disk-io.c @@ -1009,13 +1009,16 @@ int btrfs_scan_fs_devices(int fd, const char *path, { u64 total_devs; u64 dev_size; + off_t seek_ret; int ret; if (!sb_bytenr) sb_bytenr = BTRFS_SUPER_INFO_OFFSET; - dev_size = lseek(fd, 0, SEEK_END); - if (dev_size < 0) - return (int)(dev_size); + seek_ret = lseek(fd, 0, SEEK_END); + if (seek_ret < 0) + return -errno; + + dev_size = seek_ret; lseek(fd, 0, SEEK_SET); if (sb_bytenr > dev_size) { fprintf(stderr, "Superblock bytenr is larger than device size\n");