Return-Path: Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:33248 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231575AbhBLMnm (ORCPT ); Fri, 12 Feb 2021 07:43:42 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 11CCeKaK130682 for ; Fri, 12 Feb 2021 07:43:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : subject : message-id : mime-version : content-type : content-transfer-encoding : sender; s=pp1; bh=+74AMwoiMniuKprkAcymUIOsfm2fQbekNFpJgR5aN4c=; b=dmTgVNMLsIOqi7pweANOGSM5/BDhJYmxmDu1AHt2Y2jZOdHQEh+XrxsD2hLRhtEqGyMw 1YJLvQ5Yzqpj/XZ3YnuF6yolORT87/dUHIGVvo8RTQNDdwRlgb5/rg2+Eq9TD8NQ2tWJ /hF4prZYaqdORbF3o3SF3cTFBqA6Rbi3X/AQ/dlU02Z/Ip72qXsM2LHe2j/fknRQhaRe XB2yjfqUJFSn4/UV+/Pw5KzOuJKOtqE8b2FPWu1OMPnV8C/0+WbIByp/kSsVOYc2FMea AiiA9qx3QH9gFZ6I5+Oou6IzPPSwZj8Ru0cLiyPfSrUj4GIFX6KF7EamD1gKNa+dEDvI Fg== Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 36nsfnh2fc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 12 Feb 2021 07:43:00 -0500 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 11CCXt4b016352 for ; Fri, 12 Feb 2021 12:42:58 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma03fra.de.ibm.com with ESMTP id 36hskb3c73-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 12 Feb 2021 12:42:58 +0000 Date: Fri, 12 Feb 2021 13:42:54 +0100 From: Benjamin Block Subject: False Positive return_cast check Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Sender: Benjamin Block List-ID: To: Mailing List linux-smatch Hello, I hope this is the right avenue to report this. I noticed yesterday that we get a false positive report from smatch for `pathmask_to_pos()` in `arch/s390/include/asm/cio.h`. When reviewing some code I got this error while using smatch: CHECK /home/bblock/src/linux/drivers/s390/cio/device_pgid.c /home/bblock/src/linux/arch/s390/include/asm/cio.h:356 pathmask_to_pos() = warn: signedness bug returning '(-119)' Which corresponds to this helper: static inline u8 pathmask_to_pos(u8 mask) { return 8 - ffs(mask); } First I assumed this corresponds to some corner case where `ffs()` might return a negative number, or something bigger than 8 (both are not supposed to be possible); but I couldn't wrap my head around what exactly the error message is supposed to tell me with `(-119)`.=20 After some exhaustive head scratching I took a look at smatch itself and found this message is emitted by `check_return_cast.c`, and according to commit `f65a092d16cf` is supposed to warn me that we return a negative error code via an unsigned return value type. That seems to be a false positive here. Its not really something terrible important, but after I took so long to understand what this is telling me, I thought I might as well report it. --=20 Best Regards, Benjamin Block / Linux on IBM Z Kernel Development / IBM Sys= tems IBM Deutschland Research & Development GmbH / https://www.ibm.com/pri= vacy Vorsitz. AufsR.: Gregor Pillen / Gesch=E4ftsf=FChrung: Dirk = Wittkopp Sitz der Gesellschaft: B=F6blingen / Registergericht: AmtsG Stuttgart, HRB = 243294