From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from userp2120.oracle.com ([156.151.31.85]:42380 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230090AbhBOMhV (ORCPT ); Mon, 15 Feb 2021 07:37:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=0mxydfouzHxxYRBOGSD/5oEuQcVsXOMxDZqfm42tXHk=; b=UytgUcLNaeLhGK5e8j3bWCmUlBT7sA2XXXvsHe0BVjZrQpUiYj+9+tH7q0QxJajHYBbU OkSLBYm0Yut+/BLpHTY99U9j1WpbT5ZG2oGR9xRdktg0TVSsPirWOKiun0BUSHq9nVFz J8JzGKbFZhk9xKKYKQSB5k1hs3JpcLjYtAEmoqgvPwXURt68MmN/Ktu0OwiUOHvZYWzE 5s9uAAkeA6NzS/Mhjcm5jK1Ks1KydGRZ44bfvbbZ3AOnbCUrDyElmcBTY6+VC6CFkRVL 4Dw2TyFtlkDkOlCYO0oCMH1ta8g9G4JdVIb2oPt7rjjqVixJjfkLx/7bzzm9SARvQZ0J ng== Date: Mon, 15 Feb 2021 15:36:25 +0300 From: Dan Carpenter Subject: Re: False Positive return_cast check Message-ID: <20210215123625.GI2087@kadam> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-ID: To: Benjamin Block Cc: Mailing List linux-smatch On Fri, Feb 12, 2021 at 01:42:54PM +0100, Benjamin Block wrote: > 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); > } > Could you add some debug code, like this: #include "/path/to/smatch/check_debug.h" static inline u8 pathmask_to_pos(u8 mask) { __smatch_bits(mask); __smatch_implied(mask); __smatch_implied(ffs(mask)); return 8 - ffs(mask); } Then run: /path/to/smatch/smatch_scripts/kchecker /home/bblock/src/linux/drivers/s390/cio/device_pgid.c regards, dan carpenter