From patchwork Thu Sep 5 04:17:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 13791740 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 E9742CD4F50 for ; Thu, 5 Sep 2024 04:38:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nD0rUo0iZKECgz1mfgeWlPajiiX/VTTiXfcH67/TdcA=; b=jBlom1MXkvMSQd+AFpzCWQuFsG Y8YBJvz4tuxkwFLO9sMe2yH9fmH2ggXlo8QZEzlTq1ccf4IdUUNPGNkN4tNvMHX3bcgP6aG/f3I0q jGaFlcVDH66Dhj9s3r0ENrrLdmyP7O0sahP0F4sqW1ENefufo7sR8fGcAhQ0s0vOx4lytaehUbrXG SltetXQGdNt/jsU+aGJ2ggwhb4uH9RFYqkQHBvFcZAsuSgR2Jy9fpFFGhVoj/Oxu4zIQECyHoxWqB FTqh3Bhw5gAjv1LSuR+J9dfRjYhz54cwGRywmCdB6nBsAHGr3Orum3EAWgmHN8bNhw/m/tloW3/ke HDuXsh4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm4Gc-00000006xio-2JD5; Thu, 05 Sep 2024 04:38:46 +0000 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm3wl-00000006tXZ-3qr4 for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 04:18:17 +0000 Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-710ac7041c8so270061a34.1 for ; Wed, 04 Sep 2024 21:18:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725509894; x=1726114694; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nD0rUo0iZKECgz1mfgeWlPajiiX/VTTiXfcH67/TdcA=; b=PABOWAsPGobefFkVl0iOyLph2S902KjlzOuly1zTbLDhcMMwiYdMGs5uJFgODSGJwy JMVXdRKQSyOUbIM7axa1rTyj7tvfPCVCJVNT/tmyc4mDrZ10mcw77RzyY7zsrwv41dKe BkysvjKgc8gtlb9ojhBdjLT0SvtKMKyjdKEX2Wh+nAlete/OTj+kdNuVb1KziBKV02p6 9R7oqahITX/aNS71IFtA5Exw8PTpHkh85jURvqnuIVgSBUcPrgSpoyJ7IXdGV4KBgvkf pP8MPS2fU3Aho6MphPBAs7emoLbl4qPF9b/uYA3J5/Xer+Avn015OZeVkFvsjU9UrZ3m +ncg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725509894; x=1726114694; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nD0rUo0iZKECgz1mfgeWlPajiiX/VTTiXfcH67/TdcA=; b=YD6AEpOY3fhWaxVCPHg9JGTT18EfOXMwGf2FYnDAOYDGs54pEYNgazI3lnlIqX7+Dx 0kHrUbQz4z340yxMYmUVMVgaPRov+SoDR8ztBH8AMaLhoho370FPlKO8zi38kf4R8UHx 69XAhasJNK09wtHG1F8YlT43uKpjMuPoDvOqEJEk5hxJON+ivLnQipQvIN0pBlDX1a+m t2/5eI/a7b5L4tgI22F30KuLzDldMzyRnmtR84JE33ANnBgz9FTQog/G5cfSv9tOWiUx b250UYG9Robb+s8rTnDEmmFCoW1okxGWcctgkDT8wRmGwFje59VpmqCBiXSzJg8KWkUr dg+w== X-Forwarded-Encrypted: i=1; AJvYcCXgVBtIQv4LfCpcIaqfttJtgocoY25q5NrTEiVagEXnOS64oFYwZ8BXjr8jUjhkkjt3+VtxoPQkL/dTU3QlPf4k@lists.infradead.org X-Gm-Message-State: AOJu0YzNOlkcrw5zVjON78E5QntEAG6plpRjpy5xrDyW8aRvZ/LPEYZj vMK2Vrc/EOhs7X9C2GNlIdfVtOLDfDkgYPEegudW2XG6Hbyog3eO+VJUGw== X-Google-Smtp-Source: AGHT+IFZIWBeGssZlbykHlhtPJzaOPXIEAb+m9BSaPwc6IUQXl2xcYZG1msLYwzKd+swNkLxBLV4NA== X-Received: by 2002:a05:6358:88d:b0:1b5:a034:4713 with SMTP id e5c5f4694b2df-1b7ef352898mr2009643555d.0.1725509894565; Wed, 04 Sep 2024 21:18:14 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2620:15c:9d:2:13bd:b4e:4c0f:4c37]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7d4fbd8d52esm2450216a12.32.2024.09.04.21.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2024 21:18:14 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: =?utf-8?q?Pali_Roh=C3=A1r?= , Helge Deller , "K. Y. Srinivasan" , Wei Liu , Dexuan Cui , Samuel Holland , Lyude Paul , Michal Simek , Hans de Goede , linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH 21/24] Input: serio-raw - fix potential serio port name truncation Date: Wed, 4 Sep 2024 21:17:26 -0700 Message-ID: <20240905041732.2034348-22-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240905041732.2034348-1-dmitry.torokhov@gmail.com> References: <20240905041732.2034348-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240904_211815_976591_26692386 X-CRM114-Status: GOOD ( 13.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When compiling with W=1 the following warnings are triggered: drivers/input/serio/serio_raw.c: In function ‘serio_raw_connect’: drivers/input/serio/serio_raw.c:303:28: error: ‘%ld’ directive output may be truncated writing between 1 and 11 bytes into a region of size 7 [-Werror=format-truncation=] 303 | "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no)); atomic_inc_return() returns an int, so there is no reason to cast it to long and print as such. Fix the issue by removing the cast, printing it as unsigned decimal, and expanding the name from 16 to 20 bytes to accommodate the largest possible port number. Signed-off-by: Dmitry Torokhov --- drivers/input/serio/serio_raw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c index aef8301313b2..e058fef07f57 100644 --- a/drivers/input/serio/serio_raw.c +++ b/drivers/input/serio/serio_raw.c @@ -29,7 +29,7 @@ struct serio_raw { unsigned char queue[SERIO_RAW_QUEUE_LEN]; unsigned int tail, head; - char name[16]; + char name[20]; struct kref kref; struct serio *serio; struct miscdevice dev; @@ -277,7 +277,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv) } snprintf(serio_raw->name, sizeof(serio_raw->name), - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no)); + "serio_raw%u", atomic_inc_return(&serio_raw_no)); kref_init(&serio_raw->kref); INIT_LIST_HEAD(&serio_raw->client_list); init_waitqueue_head(&serio_raw->wait);