Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp88399rdh; Sat, 23 Sep 2023 02:42:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElgIHfYj1Yz/jCvHxGVUrXsQTgqtNVDj1AFQBog6ocQkWOsgbV/MbMnaab0zSK/Jj1wn0l X-Received: by 2002:a25:3255:0:b0:d3b:24b:561e with SMTP id y82-20020a253255000000b00d3b024b561emr1370723yby.42.1695462164452; Sat, 23 Sep 2023 02:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695462164; cv=none; d=google.com; s=arc-20160816; b=aOy8tzBMJg75mvE/SBsrHVumqfNDrPVe6RUxQrd6PiJZnpuNW4Y+p8OZmBqRLVvroW qbNfGmlzr/ZY4v/YfSBk7de3cAcxqx7W+KeCgdR276cQIoAqUq+/mou7u8lwK5/B+P4o V0itFhUQ1YJayp4fCujAjgTB2bxGQ4PzWmYgQ/6PlH4LiuEikUSQYWctKHLnWPA3b5uu IZvWu7eBw37VHaIYt1dThSp5pEaq2WKHlwPd3os4Os+9Wghvfq2JHBhhShwrO1NsAw8H 7zwY7XYySfFic6yzz8MV4kCoXPVaAMuplMtm9iPvyRMxwY3enxyCHUZhgC2jB6B1kheM Z0gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Pwbdp/ALGy4X1W3d5bb3j8VmlzglmaHLWQ82s+zIwjM=; fh=1mqn8XKkR+YwxFSz7RqD0E5i0qOiwkKxCMtjJIFvtL8=; b=Htmtc+OtkuvaJWlRLrg1uGVfkuIGMHwdwhpUHdesAtjzqvAAaAHEjyaY1+fwRC7wGb 9MlwaLOBLfhZk1Xzoq88K0nLx6SyW6/Df+OS4lYo6/2eRYB/qpw/kflWP9YRKClouFM2 SbgDgOAGT5huxTBDeo4A8DV4YLHVpbEZkyqZUp5UOqrU4lRLEBncFQOBYY1vOJdG6FhV N3jeOdW8w4KJ6TtwpU2+/Prc6XAoI5QlDAMvvP0Dj5KLw/BeZFodTgQQqp3MLJ+U+3nn DvMJ4WIyvjY3q5WwiPaM3GURZ20XL2yqNzZSgDRbB78Bm2wYKRJzOE2LN7vCqbVShj0r uOpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=bsXnvC+O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id a21-20020a63e855000000b00578d7a3a4fdsi5535341pgk.563.2023.09.23.02.42.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 02:42:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=bsXnvC+O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 6E2BB83887B8; Sat, 23 Sep 2023 00:15:54 -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 S230200AbjIWHPx (ORCPT + 99 others); Sat, 23 Sep 2023 03:15:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229980AbjIWHPw (ORCPT ); Sat, 23 Sep 2023 03:15:52 -0400 Received: from smtp.smtpout.orange.fr (smtp-15.smtpout.orange.fr [80.12.242.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CE30A7 for ; Sat, 23 Sep 2023 00:15:42 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id jwrbqrekTcLIgjwrbqAzVs; Sat, 23 Sep 2023 09:15:40 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1695453340; bh=Pwbdp/ALGy4X1W3d5bb3j8VmlzglmaHLWQ82s+zIwjM=; h=From:To:Cc:Subject:Date; b=bsXnvC+OsPEQQYIP6GC2EcGJcwME9UMZuNil/vQx6pXE8Vz3SIcCBxlJuXLeu8Uqj uw+ErlMH6E+a7lSNvdRjPzzE8qGDtwKYul1uni7zIapmNguUaCcOnjAoM5+IY9xYgk pwJujQ1DJpxrWbwmvXnz170LInVGPwBPVs2YfLvrHLnfgD+EFf2Flv33TkyBxC6yUl 2DnTgiOfGDV3j/I0pT0DjAWDYibH/W0bTkzpCCm9TDUOx0v14Vz6hybqdK+f3Se6E1 Dd+foaEyIbawZ71lt4+4d+Rwn6QLFbLV7ZLAanJWFfSSoFz1oXb7xYNqkYv4dlay80 FyTjIFWMxs7aA== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 23 Sep 2023 09:15:40 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Pavel Machek , Lee Jones , Bryan Wu , Linus Walleij , Jamie Iles Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-leds@vger.kernel.org Subject: [PATCH] leds: trigger: ledtrig-cpu:: Fix a warning when compiling with W=1 Date: Sat, 23 Sep 2023 09:15:38 +0200 Message-Id: <3f4be7a99933cf8566e630da54f6ab913caac432.1695453322.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no 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]); Sat, 23 Sep 2023 00:15:54 -0700 (PDT) X-Spam-Level: ** 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(-) diff --git a/drivers/leds/trigger/ledtrig-cpu.c b/drivers/leds/trigger/ledtrig-cpu.c index 8af4f9bb9cde..05848a2fecff 100644 --- a/drivers/leds/trigger/ledtrig-cpu.c +++ b/drivers/leds/trigger/ledtrig-cpu.c @@ -130,7 +130,7 @@ static int ledtrig_prepare_down_cpu(unsigned int cpu) static int __init ledtrig_cpu_init(void) { - int cpu; + unsigned int cpu; int ret; /* Supports up to 9999 cpu cores */ @@ -152,7 +152,7 @@ static int __init ledtrig_cpu_init(void) if (cpu >= 8) continue; - snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu); + snprintf(trig->name, MAX_NAME_LEN, "cpu%u", cpu); led_trigger_register_simple(trig->name, &trig->_trig); } -- 2.34.1