Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp968358ybp; Wed, 9 Oct 2019 07:02:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxcXJ6HtovP5+XSrNimOKWLfbxBzU6TJBRFw3z3wdrqC4EOCCAsNGCmtwMWeN4Ld5EjxBMc X-Received: by 2002:aa7:cfc2:: with SMTP id r2mr3031390edy.229.1570629774205; Wed, 09 Oct 2019 07:02:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570629774; cv=none; d=google.com; s=arc-20160816; b=uzJn+ZIkx8jpHfy/rhCquniBZJt0FDi8U/tXLv8BRkgrdxk9LjK0Us2iMewJxMwNdU 7AdpGoCfKN9F4FrV9rjftCtj9QvsYNh5oeWUw/D3zi+Mdub1mStIQAXs/FfQ/Lkq7kwJ 1aQPStM3sQcaZrcgTLOOptzWn9yjtdVhUmIbaugMIJK28gYYuOvfaba00P5alpjYZ9Ab NGSPm7BrxxxDYMiK9wMAQkMioB+18TVGJw/QJn5ttQ9fDQrCVk7myf0Jhhz01og4NU3D DLuVe287Sx4o3q9A7WfCLNbhPWKADXREeTo6IWilkHgJbTsHpQtldl3hiL/lasAcuoUK fTqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=KuFxysVjGvj9HNkv/L58Cim31ODyPhyJGS4wNznP1v0=; b=gYOsMjzhjYZMbTvwhIONp7+rXm4EKIVBrFMo2OL9eNgst//R79FLNtvMRwT6nke6cS hlUGICbWizjTXFs1z+JkJGuxtYZdTHHFqA3upzM2NbFcCgCSE8cz4tE9L2GNYmTppHk0 kUNDe7v1JcYUxthbXZtYjzIu5qiHGIqSyNSMrey4kEu/qVqVbcRpYSoTSdWaZJdklSbE 8qfxOF1HcuIaEH7pOlFhWUIGsR1j4j1VfMho+jbb2W3V9x99tnMmtlbVzvMRyQKD7e5M NaUwNB1sB+xNWpiqdHDqp/CEoNAIe8cT0DHNVmyeOqg2iW9eRdkG4TLWkrRyfQe65twX lRJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=YrlRJpdq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3si1184088ejq.45.2019.10.09.07.02.05; Wed, 09 Oct 2019 07:02:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=YrlRJpdq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731260AbfJIN60 (ORCPT + 99 others); Wed, 9 Oct 2019 09:58:26 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:43584 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725879AbfJIN6Z (ORCPT ); Wed, 9 Oct 2019 09:58:25 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x99Ds1P4030202; Wed, 9 Oct 2019 13:56:50 GMT 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 : content-transfer-encoding : in-reply-to; s=corp-2019-08-05; bh=KuFxysVjGvj9HNkv/L58Cim31ODyPhyJGS4wNznP1v0=; b=YrlRJpdq5+RuPMCTXFueXKSo1WJ7EbeZc6ILfpqp/V3RnH82yVBuOjuOB4sGyueRSvx2 8Tp0OAIeEap/S0ypRCu3TxosqeqRqypTgJC94SjBYkRY+2m2CDNHBfRPVdprIqUw4yen oMS5q6NQgpsXB2Fadibh2DerijspBWuGhdabJx0fUpipZbbm1zM3yPV16BCcr+ewNV6J 0hvbFqh8yHJrH8KU2e/DAj+D+KN/3xvlDk0lVcqFjAzQ3A1ogblVGOXi+atCy4N65np0 wj78tfZuwza1TF12f6hGoOMgbDBkcfAReWANH/58etQVotiJOb+879PzwNGSzpPThHIY FQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2vek4qmq5e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Oct 2019 13:56:50 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x99DraOI032368; Wed, 9 Oct 2019 13:56:49 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2vgefcr16q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 09 Oct 2019 13:56:49 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x99DuiVK029752; Wed, 9 Oct 2019 13:56:46 GMT Received: from kadam (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 09 Oct 2019 06:56:44 -0700 Date: Wed, 9 Oct 2019 16:56:33 +0300 From: Dan Carpenter To: Rasmus Villemoes Cc: Markus Elfring , kernel-janitors@vger.kernel.org, Alexander Shishkin , Andrew Morton , Andy Shevchenko , Joe Perches , Kees Cook , Nick Desaulniers , Steven Rostedt , LKML Subject: Re: [PATCH] string.h: Mark 34 functions with __must_check Message-ID: <20191009135522.GA20194@kadam> References: <75f70e5e-9ece-d6d1-a2c5-2f3ad79b9ccb@web.de> <954c5d70-742f-7b0e-57ad-ea967e93be89@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <954c5d70-742f-7b0e-57ad-ea967e93be89@rasmusvillemoes.dk> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9404 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=806 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910090133 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9404 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=881 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910090133 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ I haven't reviewed the original patch ] On Wed, Oct 09, 2019 at 03:26:18PM +0200, Rasmus Villemoes wrote: > On 09/10/2019 14.14, Markus Elfring wrote: > > From: Markus Elfring > > Date: Wed, 9 Oct 2019 13:53:59 +0200 > > > > Several functions return values with which useful data processing > > should be performed. These values must not be ignored then. > > Thus use the annotation “__must_check” in the shown function declarations. > > This _might_ make sense for those that are basically kmalloc() wrappers > in one way or another [1]. But what's the point of annotating pure > functions such as strchr, strstr, memchr etc? Nobody is calling those > for their side effects (they don't have any...), so obviously the return > value is used. If somebody does a strcmp() without using the result, so > what? OK, it's odd code that might be worth flagging, but I don't think > that's the kind of thing one accidentally adds. if (ret) { -EINVAL; } People do occasionally make mistakes like this. It can't hurt to warn them as early as possible about nonsense code. > You're also not consistent - strlen() is not annotated. And, for the > standard C functions, -Wall already seems to warn about an unused > call: > > #include > int f(const char *s) > { > strlen(s); > return 3; > } > $ gcc -Wall -o a.o -c a.c > a.c: In function ‘f’: > a.c:5:2: warning: statement with no effect [-Wunused-value] > strlen(s); > ^~~~~~~~~ That's because glibc strlen is annotated with __attribute_pure__ which means it has no side effects. regards, dan carpenter