Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1781243rwi; Thu, 3 Nov 2022 09:01:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM52FKsnG6qr+2XtQxRninosG4tRbXrVuoq8timUCqg2oYQeTEMIAtdW4DqhxdS0XLPz6+Gj X-Received: by 2002:a17:907:a40d:b0:78d:9f66:e51f with SMTP id sg13-20020a170907a40d00b0078d9f66e51fmr30541780ejc.654.1667491283538; Thu, 03 Nov 2022 09:01:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667491283; cv=none; d=google.com; s=arc-20160816; b=eOaFSdFirw+ZuJOTcj1BBB0S27Q8gc8ZzzofIZg3hqqOArnze+xamqh4vtNWQt++C4 6xP+Xbu+KlcZead7mf0wnO4xRX34YYQwCnOs+oqcBlt3xQ0aCQKRK8meq73WTktfxWBn IiThvh6ATsCENQFmqy+QRgjpvTK8XJxgqDiUDsFUpEz3EkpCzT+399CDDawpHWCEaJCL a0jobeNx85GLHgpDhMSRRVsBSZrERMA0FGKhxy7CXfhYh06wOs/w0lu4zYvMEpwmLxe9 +l5CwugpYpu27vnbzOUZeyqOB3R8HGKoa4ErsGRlkL30ud/X4IjpPicca00bN/qJItBm NKPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=w0yJDjVaa8CK7Zh+Yg+dLsD3M1CdI6efU1k/W84Y0cY=; b=HtX1FQ+w/6QM/vPtPmFhekcp217yfS+CLwWqt2QwKoi1/v4p/ycaTH5U6b0RDUJckS EFiQoQqBd0P5d25SFHUpy+x4JED+jS7HT/NZHkEl/20vlTAyoxE9H3VhYO96qv4bdWjZ R2fNM1Sa4J7ejfohS6YGeKL3bMS9l9Dr04wXe48S4SL/mjW321ES5+GfRb+1cOjfeO1z km3xtpdwERKqJwAG3XN47ZPIldCKBVSPvD9hMjVF7NK1Hx2QFDRQzgadka90k50b67hx l4vN/V6JSlXiHuJu0pNx0wo7t0Yo0zLivgZj1vnsjScDu5WXw1KD3pYmE/hQvqhjfHTo NuZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QCO7sVUY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs29-20020a1709073e9d00b007ab1b8b719csi2314070ejc.0.2022.11.03.09.00.58; Thu, 03 Nov 2022 09:01:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QCO7sVUY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231253AbiKCPZw (ORCPT + 98 others); Thu, 3 Nov 2022 11:25:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232172AbiKCPZm (ORCPT ); Thu, 3 Nov 2022 11:25:42 -0400 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C93FA1929C; Thu, 3 Nov 2022 08:25:41 -0700 (PDT) Received: by mail-oi1-x236.google.com with SMTP id m204so2308517oib.6; Thu, 03 Nov 2022 08:25:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=w0yJDjVaa8CK7Zh+Yg+dLsD3M1CdI6efU1k/W84Y0cY=; b=QCO7sVUYL78hch9+q3cvlRDg4d/U8RF/+oi24omMzqJEmtq3vxjhMM9Om7UuaszObE LnaYtBwo17UylZ7xO3o8vK354lJszs+va/RVz3DW4qZip8bGPsX/KwlFr7v4pWg41UaO oDI2HiR5Lm7YSkDb8o/dGm23bmdtUSHFkP3DGrWCXEw20GJCXuZFOVD0MPY9/hseReWv XhWedlwyjmz+lDLtLGLjlYDDO18KHhmb5Ax+IUPU6tDtj4s5KzkUT1ilyvIkIMKOTxLm K5CVIb0LC7hG4ttcVoZNmiDMhV9WO2hLVTYdHeqOC1D6iOfnO26RxmqOPhFOibPzQN9Q viXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w0yJDjVaa8CK7Zh+Yg+dLsD3M1CdI6efU1k/W84Y0cY=; b=qgJcBxWKbHSL4ho5ytgEFVRP8HITcF/Nrq9p9l4244zwYNjCLlmfjpUrpmS+AgNoSE 7zCjLRVKuvp5EjoVTpQYwKc+snMZwDyuwlewwqdSEGUdqk/9RgoPP+xU55Lz8Bzgr1Zu Rcj4noboY0TY8G1VW8WQRUdi49YfJ18XkwPCPTUb6J4T9QKZ3WY3tiNyfdSGanEj1owl jxU7efT3o/4bANhunMHEO4lRZ92x/Blcgl9I5Otz1QACeASvUjJFmdD4Vi9/4J1wU5Se MUTZYtYAAFmaL8qRAGA8+VAGqYLKzu617KELjZFkkoPuv7cHEsrfFigrJ5Rb0zlPBmiu LdLg== X-Gm-Message-State: ACrzQf34OeWuBtWgvLpjJVtbeY3E01PMHetRqtETsmSqUzY1QWF+fnrM CnyD5RwXEvULkFXfxszK79w= X-Received: by 2002:aca:1c0c:0:b0:359:fb5e:727b with SMTP id c12-20020aca1c0c000000b00359fb5e727bmr14364409oic.132.1667489141178; Thu, 03 Nov 2022 08:25:41 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id j16-20020a056830015000b00660fe564e12sm440647otp.58.2022.11.03.08.25.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 08:25:37 -0700 (PDT) Sender: Guenter Roeck Date: Thu, 3 Nov 2022 08:25:33 -0700 From: Guenter Roeck To: Randy Dunlap Cc: wangkailong@jari.cn, jdelvare@suse.com, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] hwmon: (amc6821) Fix unsigned expression compared with zero Message-ID: <20221103152533.GB146501@roeck-us.net> References: <1872639a.89.1843b5106aa.Coremail.wangkailong@jari.cn> <20221103141727.GA145042@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 03, 2022 at 08:03:35AM -0700, Randy Dunlap wrote: > > > On 11/3/22 07:17, Guenter Roeck wrote: > > On Wed, Nov 02, 2022 at 07:59:06PM -0700, Randy Dunlap wrote: > >> > >> > >> On 11/2/22 19:27, wangkailong@jari.cn wrote: > >>> Fix the following coccicheck warning: > >>> > >>> drivers/hwmon/amc6821.c:215: WARNING: Unsigned expression compared > >>> with zero: reg > 0 > >>> drivers/hwmon/amc6821.c:228: WARNING: Unsigned expression compared > >>> with zero: reg > 0 > >>> > >>> Signed-off-by: KaiLong Wang > >> > >> Hm. IDGI. What's wrong with comparing an unsigned value to > 0? > >> I mean, it could be == 0 or > 0. > >> Please explain. > > > > I don't get it either. The real problem with this driver is that error > > returns from i2c functions are not checked. However, that problem is not > > fixed by this patch. That means the patch would change behavior without > > fixing the actual problem. > > > > I wonder what kind of (broken) compiler or analyzer produces above errors. > > We'll have to watch out for similar broken "fixes". > > It says above that it's a coccicheck warning. > I see, unsigned_lesser_than_zero.cocci. It actually complains that an unsigned variable is used to hold the return code of a function which returns an int. In other words, it really tries to warn that the error return code from that function is not or not properly checked. The message is misleading for that situation. Guenter