From patchwork Fri Apr 11 10:22:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thorsten Blum X-Patchwork-Id: 14048063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 13000C369A9 for ; Fri, 11 Apr 2025 10:32:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B2A2B10E282; Fri, 11 Apr 2025 10:32:40 +0000 (UTC) X-Greylist: delayed 600 seconds by postgrey-1.36 at gabe; Fri, 11 Apr 2025 10:32:21 UTC Received: from out-182.mta1.migadu.com (out-182.mta1.migadu.com [95.215.58.182]) by gabe.freedesktop.org (Postfix) with ESMTPS id E403710E282 for ; Fri, 11 Apr 2025 10:32:17 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1744366930; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=l3nM082bM78TtBWdFK27NatUNhqNWPO8Kx/xITC8UGs=; b=Jlf6JtjmHab+Pw/38wjLXmIZuk+NOR+1Yoa9l3XrL+GggTfWjDJZN8wOb/284jxsdAOIbI 6os2tYkniByg/JaeQYvh7XEMpoavOEfWIQ6bF6yL2S8sS7/n53iZC3hJZgF7KY/1+z4Eyu Vyeg1REshTRzrcTnZ72EbSBy5C9e5SU= From: Thorsten Blum To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Cc: Thorsten Blum , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm: Use strscpy() instead of strscpy_pad() Date: Fri, 11 Apr 2025 12:22:01 +0200 Message-ID: <20250411102202.71547-1-thorsten.blum@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" kzalloc() already zero-initializes the destination buffers, making strscpy() sufficient for safely copying the names. The additional NUL-padding performed by strscpy_pad() is unnecessary. If the destination buffer has a fixed length, strscpy() automatically determines its size using sizeof() when the argument is omitted. This makes the explicit size arguments unnecessary. No functional changes intended. Signed-off-by: Thorsten Blum --- drivers/gpu/drm/drm_property.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c index 596272149a35..47f2891f3f06 100644 --- a/drivers/gpu/drm/drm_property.c +++ b/drivers/gpu/drm/drm_property.c @@ -128,7 +128,7 @@ struct drm_property *drm_property_create(struct drm_device *dev, property->num_values = num_values; INIT_LIST_HEAD(&property->enum_list); - strscpy_pad(property->name, name, DRM_PROP_NAME_LEN); + strscpy(property->name, name); list_add_tail(&property->head, &dev->mode_config.property_list); @@ -421,7 +421,7 @@ int drm_property_add_enum(struct drm_property *property, if (!prop_enum) return -ENOMEM; - strscpy_pad(prop_enum->name, name, DRM_PROP_NAME_LEN); + strscpy(prop_enum->name, name); prop_enum->value = value; property->values[index] = value;