Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4218586imm; Mon, 11 Jun 2018 08:47:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKutDX8qv4MoF/uBvvahJ4bY0guFlOw6FAYLsrH84ucOpHvZfYS5Sr7feSxRs7UT66Fov1D X-Received: by 2002:a17:902:3281:: with SMTP id z1-v6mr19225290plb.226.1528732063884; Mon, 11 Jun 2018 08:47:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528732063; cv=none; d=google.com; s=arc-20160816; b=j2YrE6u7Zl7B6QjFlHo1Wpe+JTnT2fR++2wdVNlV/qTOa+2mognqKtKrjwDfbvCMHQ 4W1C+WGBtyjZn93jBKSrDsBAWusR/gF7Gv/Q9XyYQ/ADQGKLymRZbPSOc4ncTX+FlN5X APEgfJoKeQXddoLtn1xPq+EI9B5eODTryr0ep7nY6GbPDEzYYsh3TSsCcwv8MuA7uWks oDvD997dYdzTWkGQ/57IgdO/IB8svfQ4lEZvmuG5TM/RG80EQjmjxZbKFsW4Y4msxTPq tdCBVCy0Ycb4GulvdGOyGByVCwH7R97y9hchuwdKAPFrF1v8dBZN7g2dW4btb1u4hmHK K8rg== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=I4jWLoawjjFsdp6i7l8jC2dt1EHm92Sjjp87D4VCHnA=; b=e2ytkx8CWDLANNt5iCA82Czdmm2DnKYV62CMxOI8larWBYsqSmLk2yWtFYRH3ft5Ao ZqWHpPJDq4WQmEk44j69C/d6mspcv/8YnRWNgv1jIBYzqb+0rWrL0uKGtSYUMiqR3J9O 2pG9odLyj3EiFOvDrt9oJjrXmvcjHAwPFH+CMhTXWaxwUrox566gXocgzc+TB9weaBQW 3LU0YvCk+K0rT4LxygIrcC8SUBM9jK9++Id/3cmrkS0qVhPZ3gqHYOJ0f1E+yFmRFnrb bOgywkO5YX+NTkLjgFGLWeynWmkscABZl/rARsvfc0VExaD0iMyCPbhp+SmKiadCNBxi ewEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=QR7iOfmw; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c18-v6si32331601pgf.301.2018.06.11.08.47.27; Mon, 11 Jun 2018 08:47:43 -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=fail header.i=@gmail.com header.s=20161025 header.b=QR7iOfmw; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932941AbeFKPrB (ORCPT + 99 others); Mon, 11 Jun 2018 11:47:01 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:46051 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753999AbeFKPq6 (ORCPT ); Mon, 11 Jun 2018 11:46:58 -0400 Received: by mail-lf0-f65.google.com with SMTP id n3-v6so31275690lfe.12; Mon, 11 Jun 2018 08:46:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=I4jWLoawjjFsdp6i7l8jC2dt1EHm92Sjjp87D4VCHnA=; b=QR7iOfmw64LhAEgE4bDcIHJJhk8hdRN5kfrhUodu9cxOxKToAZmuPUb9wYfzMfRMJ5 1eWCE8ylXj9QoHgfPE61wrGwfX8/FaVQZajhVQIsHIPZNjDWydUU8WxCMimzYcSCxFV3 Lm3GHLFyKqKRFiZzIRGDKpkNH86OgSvJ26WHrVLFYuJ8JWkcf3AgtJyz3gcZIHRXwdMo /H3HhhmTQ2H+JtQ0rzwoXnFc8x9cHJcXj8RUOi1Hflkw7/3Uu/+aB2Utk8hDakw+PYDI MGk3em521qVJIuHC/+JiowIwQiOwva8jJiHitIDJ1IDJ6cjEjQlPpsQKYQDqwChZQHc5 aTbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=I4jWLoawjjFsdp6i7l8jC2dt1EHm92Sjjp87D4VCHnA=; b=KvJYmUUSc3e9earP3ZJZFLB8EdNAHZzYd6+o83IHxZM63k+3OMH7sS1Vvp8ORKk0jT MlUOdXxReXYlZ2F83UEm0nCuzaXUvUdSkY0OBvPn6INmUAguQ9zaNQ2xcKcd+Vnqm0cp okyA3dx3Na2tVKUNTOxpW1kXVKbIpIvM5TeK9YvBlOs8eoNPyEtIKZDm08HC2QJd88Tt 0eiwQm6Eeyn9Phpb1PEzW6Yc1wI07f43Cel31uBQTqHAvxdZ59SYlqxbLHjZSbq+hglU fjyfKVyWBup+ueK4f5ZvE8NNZGt5JI2oq3D+4Pa58mDkf+JN+aRXEqywADI+NqmUO7xf 6NAg== X-Gm-Message-State: APt69E2QlaORcxVONLZCaN+H2dCQQUa9TXCHXhorD4N1kZ+CAMDEgR5g 4BWdpYhn18bbuTv9J/rH4dU= X-Received: by 2002:a19:d7aa:: with SMTP id q42-v6mr11049423lfi.75.1528732016226; Mon, 11 Jun 2018 08:46:56 -0700 (PDT) Received: from xi.terra (c-8bb2e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.178.139]) by smtp.gmail.com with ESMTPSA id q5-v6sm6456836ljq.33.2018.06.11.08.46.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 08:46:55 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.90_1) (envelope-from ) id 1fSP1d-0003kZ-Vo; Mon, 11 Jun 2018 17:46:34 +0200 Date: Mon, 11 Jun 2018 17:46:33 +0200 From: Johan Hovold To: Steven Rostedt Cc: Johan Hovold , Viresh Kumar , Bernd Petrovitsch , "Du, Changbin" , gregkh@linuxfoundation.org, alex.elder@linaro.org, kbuild test robot , linux-arch@vger.kernel.org, michal.lkml@markovi.net, linux-kernel@vger.kernel.org, arnd@arndb.de, yamada.masahiro@socionext.com, lgirdwood@gmail.com, broonie@kernel.org, rdunlap@infradead.org, x86@kernel.org, linux@armlinux.org.uk, linux-sparse@vger.kernel.org, mingo@redhat.com, kbuild-all@01.org, akpm@linux-foundation.org, changbin.du@gmail.com, tglx@linutronix.de, linux-kbuild@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v5 2/4] kernel hacking: new config NO_AUTO_INLINE to disable compiler auto-inline optimizations Message-ID: <20180611154633.GC13775@localhost> References: <20180606095714.1d3c2def@vmware.local.home> <20180606142600.GN13775@localhost> <20180606142622.2338abf6@vmware.local.home> <20180607041718.qpqucjzlvcm5h3gn@vireshk-i7> <20180607074628.kd3iyxevwj3ypzbr@intel.com> <20180607083856.ealw62v3wx43zeqz@vireshk-i7> <1303b1abf9f9229a8d3ccbb68a3e413266b360d7.camel@petrovitsch.priv.at> <20180607091025.m7dfix3e2xbwx4cs@vireshk-i7> <20180607091816.GT13775@localhost> <20180608160355.67712eb8@vmware.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180608160355.67712eb8@vmware.local.home> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 08, 2018 at 04:03:55PM -0400, Steven Rostedt wrote: > On Thu, 7 Jun 2018 11:18:16 +0200 > Johan Hovold wrote: > > > > If you want to work around the warning and think you can do it in some > > non-contrived way, then go for it. > > > > Clearing the request buffer, checking for termination using strnlen, and > > then using memcpy might not be too bad. > > > > But after all, it is a false positive, so leaving things as they stand > > is fine too. > > Not sure how contrived you think this is, but it solves the warning > without adding extra work in the normal case. > > -- Steve > > diff --git a/drivers/staging/greybus/fw-management.c b/drivers/staging/greybus/fw-management.c > index 71aec14f8181..4fb9f1dff47d 100644 > --- a/drivers/staging/greybus/fw-management.c > +++ b/drivers/staging/greybus/fw-management.c > @@ -150,15 +150,18 @@ static int fw_mgmt_load_and_validate_operation(struct fw_mgmt *fw_mgmt, > } > > request.load_method = load_method; > - strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_SIZE); > + strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_SIZE - 1); > > /* > * The firmware-tag should be NULL terminated, otherwise throw error and > * fail. > */ > - if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') { > - dev_err(fw_mgmt->parent, "load-and-validate: firmware-tag is not NULL terminated\n"); > - return -EINVAL; > + if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 2] != '\0') { > + if (tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') { > + dev_err(fw_mgmt->parent, "load-and-validate: firmware-tag is not NULL terminated\n"); > + return -EINVAL; > + } > + request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] = '\0'; > } Well, I think it's quite far from obvious what is going on above, and not least why things are being done this way (which a comment may help with). And just NUL-terminating the (automatic) buffer before returning wasn't enough? Then it may be better to do away with strncpy completely. But should we really be working around gcc this way? If the implementation of this new warning isn't smart enough yet, should it not just be disabled instead? Thanks, Johan