Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3224768rdh; Thu, 28 Sep 2023 06:20:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH1wza3qCEAcgSK4PDffXyNnLY+8M5vNkaBufabeaY38Sx0HZ7fuLUpUt2ucUUrGu18wcGz X-Received: by 2002:a05:6870:c6a2:b0:1be:f8d9:7bdd with SMTP id cv34-20020a056870c6a200b001bef8d97bddmr1236078oab.6.1695907245692; Thu, 28 Sep 2023 06:20:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695907245; cv=none; d=google.com; s=arc-20160816; b=zJe95tb7f9PJJQQa0lvdI4CqsfHVNJdRtFrZNYgw4iL7ut9nSYyCw94TwMtrPbKEKG pozLlWnpdqtcXuZ3lX7Upmh26o8x4r1F3Z1HnmD6R1BvGPg64bFhNUziojGHPCVfiDb+ onOjigTAiIAgX6epJbLps5iub+2SFkrJY+7pe74Dn+D43fIzLriBBpMpcLJHO+9XqL8m dd8rVMHbaizWEfSEnFkaSEDohzLPQVQ1aYOmmmEa7jQeCGLbatv/fThY0hXJIJl94Wx1 c299jg8aDQZWH+p9yEM4JvDo989i2k65ALU1p0yMRuATmfim/RPV+NMutRUhK1htoe8k lhWA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=5f0pKiEJ2ncuP3D4gO2/E+oCFGwvkazXLC/drxG1Bzs=; fh=oE0SMp7gU85T7mZbv1sApuclFXDQPXZjktTD/Sdh848=; b=SVdjXUaFx40+FkcY+4YxSyoffcWy7DybNDHMKxyjuSnyKYlPmVbf1Ko2wfDcc7PQD+ saA2fDyFaF5QaWI4jXdT3gL0166soIxPHrpged3Gy8QwzFeQpVdbgRBUoC/+RifYJyAH lruQvdhgOV/E466bROGWQJ6pYwRqv3LD1CcjFu+VtSLT2Hq1z0PrF7NUECZxTXA1eMJa klvmzGBEq/jThL6w7WJsE/QBmpvYy3SUnJXXMP7piEhWFYpEbS2YCu4riAZ/MmOp0hTn nAH5CSKVRQZxlMlAEk6/DL2JmC2njidhkTddSjgItRqM5+1Q+s+OhmJmrCcOuhmdZLnf i67w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bJXtpu6s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id j191-20020a6380c8000000b0056513361b4fsi18079563pgd.741.2023.09.28.06.20.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 06:20:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bJXtpu6s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 7FC738052BDF; Thu, 28 Sep 2023 06:10:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232674AbjI1NKH (ORCPT + 99 others); Thu, 28 Sep 2023 09:10:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232600AbjI1NKF (ORCPT ); Thu, 28 Sep 2023 09:10:05 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F46F199; Thu, 28 Sep 2023 06:10:03 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4134BC433C8; Thu, 28 Sep 2023 13:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695906603; bh=GLVG9ldXyJU6qewPVL4UMRgmAme+5Qm869GRWAEEMoA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bJXtpu6sUggzT2YIoRwqecDse1Tdkpvkb8C1qJ0i1WD9bIhbeHqT22lmudzlCxgCV hrJ7qzQzHh7ibpP8bLWIYz6nh+5IxVsmMN9oiVakOWYG4CgdXUQ6aA7jZdMst1Vimd LFP60ebWQ23Pkx8nZcyUr9BlTOvi0LAjtPfZFCyDHt41nOcEY9yFbEDchfXUFSYpzR t3aXo6vGnWmz+nPHJk5VztLwmq1J89XTcQG2ZD4+JRzq06lMqrF9JHQCy8dFwA9nZw vrn57oB6EbSwjzzCKCsrzccz3PL1K933E2Ed4qGQuIoOBVkWoKKvrrXvdKxexoVuCx 0SkLYf7cQPGNg== Date: Thu, 28 Sep 2023 14:09:58 +0100 From: Lee Jones To: Christophe JAILLET Cc: Pavel Machek , Bryan Wu , Linus Walleij , Jamie Iles , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-leds@vger.kernel.org Subject: Re: [PATCH] leds: trigger: ledtrig-cpu:: Fix a warning when compiling with W=1 Message-ID: <20230928130958.GH9999@google.com> References: <3f4be7a99933cf8566e630da54f6ab913caac432.1695453322.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3f4be7a99933cf8566e630da54f6ab913caac432.1695453322.git.christophe.jaillet@wanadoo.fr> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 28 Sep 2023 06:10:23 -0700 (PDT) On Sat, 23 Sep 2023, Christophe JAILLET wrote: > In order to teach the compiler that 'trig->name' will never be truncated, > we need to tell it that 'cpu' is not negative. > > When building with W=1, this fixes the following warnings: > > drivers/leds/trigger/ledtrig-cpu.c: In function ‘ledtrig_cpu_init’: > drivers/leds/trigger/ledtrig-cpu.c:155:56: error: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 5 [-Werror=format-truncation=] > 155 | snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu); > | ^~ > drivers/leds/trigger/ledtrig-cpu.c:155:52: note: directive argument in the range [-2147483648, 7] > 155 | snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu); > | ^~~~~~~ > drivers/leds/trigger/ledtrig-cpu.c:155:17: note: ‘snprintf’ output between 5 and 15 bytes into a destination of size 8 > 155 | snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Fixes: 8f88731d052d ("led-triggers: create a trigger for CPU activity") > Signed-off-by: Christophe JAILLET > --- > drivers/leds/trigger/ledtrig-cpu.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) I made the subject line less generic and applied it, thanks. -- Lee Jones [李琼斯]