From patchwork Wed Sep 6 15:47:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 111797 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp966812ybm; Wed, 6 Sep 2017 08:48:18 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5I95sQ3p4R0IVlfQc2Jot79nDbDYf0HPJHSWP5p0naO226KPsL1JxxS3laCeVwS7DQrZY+ X-Received: by 10.99.141.74 with SMTP id z71mr7986429pgd.407.1504712898738; Wed, 06 Sep 2017 08:48:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504712898; cv=none; d=google.com; s=arc-20160816; b=E/rhOaAV2KxvYre9spWJP/dJnQxmheBcTB0+PoACx56Axhunw8riwDRNsReWE68iSU diirRqr4DnXFsbkU8p+B6CKgebqttxigIWMRbDvSnv900Qqd4bs0VhD2b9yqiX1NhU1p 8SN3eZ02DDOKNLR/HNsdhep0wMEKoEl4uEUo+VdpUgWuqnviMS7dLEVfroingVRuTgYb mz579tOlgyeTCzp1/ijjXlMGHlYhmMWuNJApWKt7VqFtjkIjfjDkElbqNi8Co27gzcjg qB8gNEAV6qoX0bNAYxzLPwYPkOAiGjvgDeZI6iM7mt0V7x186YaZsyAMwVK7GdPGW1rK 9Eqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=GhG5w+asmd/d8dRLnwS0P6A88K90XwViJpLDNgudjF0=; b=JR0sFWgGGTi7uJ33HaBls5AuuaDnvlfUoO/po7cVViXsbUnDpGHhwlQJyoDoTHNk/e Hd1MVWPqvscGyjf+/fcrFlMkuDyMw8zbQoWdOXZJln6GHMlHMsJR6UDLgE3GojOkWHMn 9Nr6PlEEt0nu5AfFWdG0nBRr/ze93Q1SSOsl5ZBlXmfbZ6KjUjbKkZdz4P8fIl2T/quA mdJLLvyl2pld5Cbjt2gBq5HuQ4DGtJR7uMmWkyriw7FI26gx5h01SLJ5T6syKhIIMdju l+n7QFzly+1xs/V8bDN9pdKQeSWB5X6PlVKvUhMXbGymMmDCruBvySVTu4+n8+UmZfq1 dOvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 11si91052plc.450.2017.09.06.08.48.18; Wed, 06 Sep 2017 08:48:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754146AbdIFPsR (ORCPT + 7 others); Wed, 6 Sep 2017 11:48:17 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:64115 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754134AbdIFPsQ (ORCPT ); Wed, 6 Sep 2017 11:48:16 -0400 Received: from wuerfel.lan ([95.208.190.237]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0M57sc-1dXets3V66-00zHBF; Wed, 06 Sep 2017 17:47:59 +0200 From: Arnd Bergmann To: Mika Westerberg , Andy Shevchenko , Linus Walleij Cc: Arnd Bergmann , Dmitry Torokhov , Hans de Goede , Wei Yongjun , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] gpio: acpi: work around false-positive -Wstring-overflow warning Date: Wed, 6 Sep 2017 17:47:45 +0200 Message-Id: <20170906154756.2133726-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:MFngi/Bev4gwQuN65nCysQqGLG+6pHk1nJEjwdW/vW9ir6pdbxC kX4466z3lRUhwevjYRaDIywFp+wX8bm0G9daqw1M2B5V3mm5Wn/8Au5VTztW8vpwtb4MC98 NWkUlxUbMNEwiYNBhV+2+wJDEb37A7+h49/gZse9+vwliusGVauaOSFRWxPQ8ugtmjC5zWW R8LsFTxGeGGklbhaTIKKA== X-UI-Out-Filterresults: notjunk:1; V01:K0:GmvlcOniEo0=:5pqHrDHrfIDXYMcVwN4ziG zfWWgIToJLOQW6zQybNj6yOhU6n2I2FVeyVr/vhlhDWQpZbfnlVFuUpi5EyDwSVVkbPECn/kj yAG6fEcfs7GBeCsMLt+s2tkv0XECeyq0PVSPBS8BvIhYJd8aHT6kl9+EoJBNgCfchTQhmuJd0 TNwu9oRj5oXpXvzfJqbz2ahdlmHgixgtNA77zf2fIoBU66mI+rRGd1t9gdfvP8kkBsLqb57kj fkMt1ShUv5/o0mEp7UGez5oufuUo0bXDOMh4Klg2l9yVdgK0pjat0YT/YF0eSqJwgUocgJeXR qyoDCpeI8sDYMPOfqCvWiFhd2iVOhqGaJAJdB92sjH3oBtmsqMgmWRINCTkTFfYNsmbzukURE oSSrwd/sIVU0glmFUTzkhBME9b629Gn2OeijdyzQOUjQdWeeG4sDH6xZ2IpLguaymqNASd7e+ gB+DnlHWBmT1DWrKzak45PYFN5JhrseLhKvutGo7ayWrhaOmODqHxO3aCOoq87nt+qzKs3j8v /5rswIL0DucRh4iIj7MwRP4aTAhRZj5qU7EMUvQUJavvDeSBR6zc9/63MzZlFo5JOyFRI4Y3Y PfpQym6iQzgJTXmEydeU8edPBBswUDXfpGKdv/eEHjOxddl+KRL+p+z4pBCKd4XkVtJUpkcTB BGi7BQJn9HId4ztzVjDY2CesNlLWEMw8UW9bwnDW62AI+gaKsl9vdJMOW615LavxI8GGreDbB Nl4Koqe1PNsjH8/aDPFXGHSUOyrvrqSpeC04rQ== Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org gcc-7 notices that the pin_table is an array of 16-bit numbers, but fails to take the following range check into account: drivers/gpio/gpiolib-acpi.c: In function 'acpi_gpiochip_request_interrupt': drivers/gpio/gpiolib-acpi.c:206:24: warning: '%02X' directive writing between 2 and 4 bytes into a region of size 3 [-Wformat-overflow=] sprintf(ev_name, "_%c%02X", ^~~~ drivers/gpio/gpiolib-acpi.c:206:20: note: directive argument in the range [0, 65535] sprintf(ev_name, "_%c%02X", ^~~~~~~~~ drivers/gpio/gpiolib-acpi.c:206:3: note: 'sprintf' output between 5 and 7 bytes into a destination of size 5 sprintf(ev_name, "_%c%02X", ^~~~~~~~~~~~~~~~~~~~~~~~~~~ agpio->triggering == ACPI_EDGE_SENSITIVE ? 'E' : 'L', ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pin); ~~~~ As suggested by Andy, this changes the format string to have a fixed length. Since modifying the range check did not help, I also opened a bug against gcc, see link below. Fixes: 0d1c28a449c6 ("gpiolib-acpi: Add ACPI5 event model support to gpio.") Cc: Andy Shevchenko Link: https://patchwork.kernel.org/patch/9840801/ Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82123 Signed-off-by: Arnd Bergmann --- drivers/gpio/gpiolib-acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Mika Westerberg diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 4d2113530735..eb4528c87c0b 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -203,7 +203,7 @@ static acpi_status acpi_gpiochip_request_interrupt(struct acpi_resource *ares, if (pin <= 255) { char ev_name[5]; - sprintf(ev_name, "_%c%02X", + sprintf(ev_name, "_%c%02hhX", agpio->triggering == ACPI_EDGE_SENSITIVE ? 'E' : 'L', pin); if (ACPI_SUCCESS(acpi_get_handle(handle, ev_name, &evt_handle)))