Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp335205rdb; Thu, 24 Aug 2023 07:34:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUOf3sKHqDEw+nnRPK4Ps/uEtXGcn1h9TvoTcLWyGxybptlADUETnHL4ZdIIbd2oGLGE8g X-Received: by 2002:a2e:83cc:0:b0:2b6:e958:d03 with SMTP id s12-20020a2e83cc000000b002b6e9580d03mr11020727ljh.30.1692887645409; Thu, 24 Aug 2023 07:34:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692887645; cv=none; d=google.com; s=arc-20160816; b=W3nItQ/5Zp1gUfI44M1mQ5Ok+qn3tFgjcXAgm76hYbqnnRNTbqHUrQ3r8Uf5fxy9PX iYipY1LRvFqKpqKRtN/s69YsJQSTzHa59BSts+YJPeevdxQdiXpyBuxq7PJQaqUkkZ6j 5DqwxG8ECyPCYJ1lfTl2mmKHCIb02cF4E+F8k4WxTMWQSpFBTENJ7aIdMGDVe8AIUY5H WPlXPJKiHg7y8dKYXSUIJw1ngxghyO0o36YBK30xT8T2vLK0ll2QPjnC50zLGXp57rvz SsVf5dFLcUFz789y5sNsYZ5hyRJC9AzH9lHVxc9q+A2kJq+SSfnp/+YXdsKPpjvSa1+I ilBg== 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=LzYjrIv0ByjZBQzOigoA1Jm4ZfQwJYE1iz5009/ygY8=; fh=HbRtPv3lfK1Ug+G8Uo7aoMCEV25OBc4AD6KDne9KASM=; b=ySPHiak1dLKqaKZSMcdj2UXe9wElfKS5wVwRDJQPQpU+ZpBSTYMdFFLYfUHaEHOL2Z YUn3p6+yyo8HyAH4AZeaWPzXbaNN7ENa8+qfDJs8p+90K8SrK8ImvF14xrl5A3+Cl8Zv 1DrZUc8DQQDUuN+wzvCTqkpovSQhCxD+86VxRgCNgnQFftFXwmVJ/EEQ2EeL2GZBMkmJ Ra0R4N+JashaZ0UbQYflHO95RFl7TZMV4lUXy0w43TlBPUtJqH9RGtU6wfhL21Ag9L4G JGgdBCNyZUpSOXkv21FjCpgundh+FU2VFXE0njedjwKI3v8/vrIc1pqOOGn+Y9mAVJ/Y gkLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AuBnRV8U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lc24-20020a170906dff800b00993860a6d3fsi10005299ejc.281.2023.08.24.07.33.39; Thu, 24 Aug 2023 07:34:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AuBnRV8U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241188AbjHXMBs (ORCPT + 99 others); Thu, 24 Aug 2023 08:01:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241259AbjHXMBc (ORCPT ); Thu, 24 Aug 2023 08:01:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 182821995; Thu, 24 Aug 2023 05:01:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AAF0B60C3E; Thu, 24 Aug 2023 12:01:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 974C3C433C8; Thu, 24 Aug 2023 12:01:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692878489; bh=QTIGKK7F8/lFS50Cqf8mM1HlzLueDyrtaK91NGV0D/U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AuBnRV8UQt+PgmaIShUYDc82r5dMhR03l70cLXuhps8PYDeubSw2tFlvF8b2ehJVr /kXYH7PsJzDcxmHUCKf92bNUj5G+8JzlJZRjlXyIJKQutxX8EWF6D0FpBPC47bUR5R miUu82WHjmo4yKazuPL82ViiettYz1RiB04EgoHMtAZpAJfS4ZQTfeuabA5WtJRc7/ s7ls6WUJHtcXQpGKKFZkOJSky2Sr4ZncOvdHCYbeLlHNjoqLvfR3I84Jz9Ktn2gBOO dM6P23XW7H1xQYJCn1cs2xBQ5QR/KlA/NI5t3G8Bz5zlg6/Dmx5YuDZoqdJa/phJ9A 9FI4OHUQmhIUg== Date: Thu, 24 Aug 2023 13:01:24 +0100 From: Lee Jones To: Jani Nikula Cc: Thierry Reding , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Jonathan Hunter , linux-tegra@vger.kernel.org, Mikko Perttunen Subject: Re: [PATCH 15/20] drm/tegra/hub: Increase buffer size to ensure all possible values can be stored Message-ID: <20230824120124.GR1380343@google.com> References: <20230824073710.2677348-1-lee@kernel.org> <20230824073710.2677348-16-lee@kernel.org> <87r0ns4weq.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87r0ns4weq.fsf@intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 24 Aug 2023, Jani Nikula wrote: > On Thu, 24 Aug 2023, Thierry Reding wrote: > > On Thu, Aug 24, 2023 at 08:37:00AM +0100, Lee Jones wrote: > >> When converting from int to string, we must allow for up to 10-chars (2147483647). > >> > >> Fixes the following W=1 kernel build warning(s): > >> > >> drivers/gpu/drm/tegra/hub.c: In function ‘tegra_display_hub_probe’: > >> drivers/gpu/drm/tegra/hub.c:1106:47: warning: ‘%u’ directive output may be truncated writing between 1 and 10 bytes into a region of size 4 [-Wformat-truncation=] > >> drivers/gpu/drm/tegra/hub.c:1106:42: note: directive argument in the range [0, 4294967294] > >> drivers/gpu/drm/tegra/hub.c:1106:17: note: ‘snprintf’ output between 6 and 15 bytes into a destination of size 8 > > > > I wish there was (perhaps there is?) a better way to annotate that i > > will always be within a given range. In practice this is always going to > > be smaller than 10 and even in future hardware I wouldn't expect this to > > ever exceed anything like 32 or 64, so 8 characters is already generous. > > I assume you could do > > snprintf(id, sizeof(id), "wgrp%u", (unsigned char)i); > > but it's perhaps less obvious than just increasing the size of the > buffer. I had the very same thought process. -- Lee Jones [李琼斯]