From patchwork Fri Oct 8 22:27:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= X-Patchwork-Id: 12546637 X-Patchwork-Delegate: bhelgaas@google.com 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 036C2C43217 for ; Fri, 8 Oct 2021 22:27:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD69D61027 for ; Fri, 8 Oct 2021 22:27:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243656AbhJHW3b (ORCPT ); Fri, 8 Oct 2021 18:29:31 -0400 Received: from mail-wr1-f41.google.com ([209.85.221.41]:40901 "EHLO mail-wr1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231852AbhJHW3b (ORCPT ); Fri, 8 Oct 2021 18:29:31 -0400 Received: by mail-wr1-f41.google.com with SMTP id i12so21246021wrb.7; Fri, 08 Oct 2021 15:27:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=czFz26TUpS008YGLjPJ2Pa8iufQcGRqEsfBe/MkTKGU=; b=sSdr5/zkXPd0DXAYycVA3SG2vIvM2vRwkmgLHhfW7q9UjyhRXlNpLkqq10SVhF+TOK 1XxXDcqfWKLiJon/p2Ydwg+ftYifqlcL89TVheZ04UuFjd7O3xetnDQCZ69OmN7qlbYZ rvFgSMz8weodCfJiegFAdN4H2fDygoXw5OGK2RlhOaLEY0QpcXiRd5jJ4ehV2q78IQ33 c1tuvSu8y5rdEiHYlTILgmc4MVJEABtpnayv+idPsb1MGL0wyeUpWOUyVqIk5laU2COS vz7ntNKupQ9fMrT/Y8sxoKc1bx2DmRNrwfTRK0Cj8U1U+da/AI0U3hQcxC1QbLGTaLA9 THdQ== X-Gm-Message-State: AOAM533jO39xFl3bmKzAeffi3dccARG1QY1Ayz6SRrkIy5vG/e1RT+uL 9iUFSoq0iCNZSJDHR1wK+5k= X-Google-Smtp-Source: ABdhPJxrQlnZz3Rvdgngn6POTEAbYZH0nFyW1f4PMActlBm6V+wpXKsV2Byc16g06QdvjnOQarnHrQ== X-Received: by 2002:a5d:56cc:: with SMTP id m12mr7245683wrw.22.1633732054641; Fri, 08 Oct 2021 15:27:34 -0700 (PDT) Received: from workstation.lan ([95.155.85.46]) by smtp.gmail.com with ESMTPSA id b15sm549577wrr.90.2021.10.08.15.27.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Oct 2021 15:27:34 -0700 (PDT) From: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= To: Bjorn Helgaas Cc: Lorenzo Pieralisi , Boqun Feng , Long Li , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH 1/3] PCI: hv: Remove unnecessary integer promotion from dev_err() Date: Fri, 8 Oct 2021 22:27:30 +0000 Message-Id: <20211008222732.2868493-1-kw@linux.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Internally, printk() et al already correctly handles the standard integer promotions, so there is no need to explicitly "%h" modifier as part of a format string such as "%hx". Thus, drop the "%h" modifier as it's completely unnecessary (N.B. this wouldn't be true for the sscanf() function family), and match preferred coding style. Related: commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of unnecessary commit 70eb2275ff8e ("checkpatch: add warning for unnecessary use of %h[xudi] and %hh[xudi]") https://lore.kernel.org/lkml/CAHk-=wgoxnmsj8GEVFJSvTwdnWm8wVJthefNk2n6+4TC=20e0Q@mail.gmail.com/ No change to functionality intended. Signed-off-by: Krzysztof Wilczyński --- drivers/pci/controller/pci-hyperv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index 67c46e52c0dc..6733cb14e775 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -3126,14 +3126,14 @@ static int hv_pci_probe(struct hv_device *hdev, if (dom == HVPCI_DOM_INVALID) { dev_err(&hdev->device, - "Unable to use dom# 0x%hx or other numbers", dom_req); + "Unable to use dom# 0x%x or other numbers", dom_req); ret = -EINVAL; goto free_bus; } if (dom != dom_req) dev_info(&hdev->device, - "PCI dom# 0x%hx has collision, using 0x%hx", + "PCI dom# 0x%x has collision, using 0x%x", dom_req, dom); hbus->bridge->domain_nr = dom; From patchwork Fri Oct 8 22:27:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= X-Patchwork-Id: 12546639 X-Patchwork-Delegate: bhelgaas@google.com 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4541C43219 for ; Fri, 8 Oct 2021 22:27:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CFC6F60F35 for ; Fri, 8 Oct 2021 22:27:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231852AbhJHW3c (ORCPT ); Fri, 8 Oct 2021 18:29:32 -0400 Received: from mail-wr1-f53.google.com ([209.85.221.53]:45632 "EHLO mail-wr1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243647AbhJHW3c (ORCPT ); Fri, 8 Oct 2021 18:29:32 -0400 Received: by mail-wr1-f53.google.com with SMTP id r10so33891422wra.12; Fri, 08 Oct 2021 15:27:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G46wgdVxBxnvmODzCOrsOtpCPNJX7A0vCQdGPPqp6WI=; b=JWeS3eaIyI6g1zcR3aMPSv5SLc+aQTiSguxzq8kdW/72ozaLZ6/jsfLuD9PFwDcVea wGNb1p47YX5pZzMuhiobT5lSgDHRhlWI17TyDg5XOsrFgcGsspKMN5bry5jJYB5gc41k SKgKpTYg5Ndr7Q2mgzBkedRN5aSqFC5pXvhnH8FvfRsNG9CWQYemlh3wgr9+M9R66G/6 W3CuxoUORbbe9GDVTkXru07wMzB167xrgrTyQHke+Ol4oweRIVgCq9d2spmaFr7JSP5Y 9ShfmZrDuVMuz0qbQUfQvQ/kspNcwbYEKs4OOyLsFWg0f/INP9Zw/6vBwRKwQd/pD4nB 59rg== X-Gm-Message-State: AOAM530Qu1k4VHWbbiWbaX0vJvSl53oj9iGRNxIsBnquCv/2JSIL8wL/ Ez95+VCm2Mq6QLazEL4Pp8HOyKMlfO/3Sw== X-Google-Smtp-Source: ABdhPJxpgThc3Xp7Vgr8G3M9wX/3xUTWaomBe3zJZNM5TCllVi/yrKbzEv5hfH5BQ3kbnJ5mgHOpFw== X-Received: by 2002:a05:600c:230f:: with SMTP id 15mr6370470wmo.19.1633732055688; Fri, 08 Oct 2021 15:27:35 -0700 (PDT) Received: from workstation.lan ([95.155.85.46]) by smtp.gmail.com with ESMTPSA id b15sm549577wrr.90.2021.10.08.15.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Oct 2021 15:27:35 -0700 (PDT) From: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= To: Bjorn Helgaas Cc: Lorenzo Pieralisi , Boqun Feng , Long Li , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH 2/3] PCI: iov: Update format string type to match variable type Date: Fri, 8 Oct 2021 22:27:31 +0000 Message-Id: <20211008222732.2868493-2-kw@linux.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211008222732.2868493-1-kw@linux.com> References: <20211008222732.2868493-1-kw@linux.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Functions pci_iov_sysfs_link() and pci_iov_remove_virtfn() take a Virtual Function (VF) ID as an integer value and then use it to assemble the desired name for the corresponding sysfs attribute (a symbolic link in this case). Internally, both functions use sprintf() to create the desired attribute name, and leverage the "%u" modifier as part of the format string used to do so. However, the VF ID is passed to both functions as a signed integer type variable, which makes the variable type and format string modifier somewhat incompatible. Thus, change the modifier used in the format string to "%d" to better match the variable type. No change to functionality intended. Signed-off-by: Krzysztof Wilczyński --- drivers/pci/iov.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index dafdc652fcd0..056bba3b4236 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -140,7 +140,7 @@ int pci_iov_sysfs_link(struct pci_dev *dev, char buf[VIRTFN_ID_LEN]; int rc; - sprintf(buf, "virtfn%u", id); + sprintf(buf, "virtfn%d", id); rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf); if (rc) goto failed; @@ -322,7 +322,7 @@ void pci_iov_remove_virtfn(struct pci_dev *dev, int id) if (!virtfn) return; - sprintf(buf, "virtfn%u", id); + sprintf(buf, "virtfn%d", id); sysfs_remove_link(&dev->dev.kobj, buf); /* * pci_stop_dev() could have been called for this virtfn already, From patchwork Fri Oct 8 22:27:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= X-Patchwork-Id: 12546641 X-Patchwork-Delegate: bhelgaas@google.com 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C711C433F5 for ; Fri, 8 Oct 2021 22:27:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 15A3560F51 for ; Fri, 8 Oct 2021 22:27:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243678AbhJHW3e (ORCPT ); Fri, 8 Oct 2021 18:29:34 -0400 Received: from mail-wr1-f52.google.com ([209.85.221.52]:33512 "EHLO mail-wr1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243668AbhJHW3d (ORCPT ); Fri, 8 Oct 2021 18:29:33 -0400 Received: by mail-wr1-f52.google.com with SMTP id m22so33986901wrb.0; Fri, 08 Oct 2021 15:27:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tRYb2LPqEkxBD8lAFNonDclv6oFLdcwFLdTj/5b6MDk=; b=LyBFFZsf89P0e+LemiwYQniJYmZiCGMYuerx7adwNjIW7loaYFfsV5v5kyrFPRyNHa dejrjOqXbWwgGNUyqRAhJKcJLFcAIIheQmVitqs0EkJFyko0kBQ6iWGHQtiMhebAcSOx C5PTYPpvu6lOQvzbjc0OpsK7NeJXGs7iXl1VcrdU/FDk1duOIdmlReYYS61kZZaxAKjS LslgAAmIMbRHA7MKrglMtkR8MxSPklXfz437MSHj+W0kmTHOd16KkFMnOPK+3NQ5shSH GVX3hozar2lv3jyvDo+txEoI77Wmm5IkSyFrwUM+/2LY2rEPrh9TrkU78winVkSEEElm a3QA== X-Gm-Message-State: AOAM530L0wy56+uGI1cBQavXtGBoUR4l1tU0F+Zl1i4ja2Ud/f08e5PK Avx7hVmdMeBNlWGmCCtunfE= X-Google-Smtp-Source: ABdhPJykfILUWlH/p9qgCZRY8huJyNxoIwFsVOgEfc1eHeJlb/8jzAS/o+YbCbohkm4IdP2ZkhwlNg== X-Received: by 2002:adf:bb49:: with SMTP id x9mr7243973wrg.413.1633732056696; Fri, 08 Oct 2021 15:27:36 -0700 (PDT) Received: from workstation.lan ([95.155.85.46]) by smtp.gmail.com with ESMTPSA id b15sm549577wrr.90.2021.10.08.15.27.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Oct 2021 15:27:36 -0700 (PDT) From: =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= To: Bjorn Helgaas Cc: Lorenzo Pieralisi , Boqun Feng , Long Li , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH 3/3] PCI: Update variable type to match sscanf() format string Date: Fri, 8 Oct 2021 22:27:32 +0000 Message-Id: <20211008222732.2868493-3-kw@linux.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211008222732.2868493-1-kw@linux.com> References: <20211008222732.2868493-1-kw@linux.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org To test whether a string contains a valid PCI device path formatted as the "/." address (see output from "lspci -P" as an example; such format can also be provided as part of kernel command-line parameters), the function called pci_dev_str_match_path() can be used. Internally, pci_dev_str_match_path() function uses sscanf() and the "%x" format string as part of its path matching implementation where it would parse a given value as a unsigned hexadecimal number. This particular format string type requires the argument to be of an unsigned int type. Thus, to match given format string requirements and also safeguard against a potential undefined behaviour, change type of the variables passed to sscanf() to unsigned int accordingly. No change to functionality intended. Signed-off-by: Krzysztof Wilczyński --- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index ce2ab62b64cf..7998b65e9ae5 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -269,7 +269,7 @@ static int pci_dev_str_match_path(struct pci_dev *dev, const char *path, const char **endptr) { int ret; - int seg, bus, slot, func; + unsigned int seg, bus, slot, func; char *wpath, *p; char end;