From patchwork Thu Jan 25 13:14:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?RnLDqWTDqXJpYyBCb25uYXJk?= X-Patchwork-Id: 865892 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zS2Zs1jrpz9sNr for ; Fri, 26 Jan 2018 00:15:16 +1100 (AEDT) Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zS2Zr2D33zDrDJ for ; Fri, 26 Jan 2018 00:15:16 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=frediz@linux.vnet.ibm.com; receiver=) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3zS2Zb3PMdzDr62 for ; Fri, 26 Jan 2018 00:15:02 +1100 (AEDT) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0PDE90L146151 for ; Thu, 25 Jan 2018 08:15:00 -0500 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0b-001b2d01.pphosted.com with ESMTP id 2fqfdy975u-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 25 Jan 2018 08:14:59 -0500 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 25 Jan 2018 13:14:57 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 25 Jan 2018 13:14:56 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w0PDEtA848627760; Thu, 25 Jan 2018 13:14:56 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7852D52045; Thu, 25 Jan 2018 12:07:17 +0000 (GMT) Received: from smtp.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.1]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 65FE65203F; Thu, 25 Jan 2018 12:07:17 +0000 (GMT) Received: from kin.test.toulouse-stg.fr.ibm.com (kin.test.toulouse-stg.fr.ibm.com [9.101.18.11]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 9CA2422039A; Thu, 25 Jan 2018 14:14:55 +0100 (CET) From: =?utf-8?b?RnLDqWTDqXJpYyBCb25uYXJk?= To: skiboot@lists.ozlabs.org Date: Thu, 25 Jan 2018 14:14:55 +0100 X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 18012513-0020-0000-0000-000003EE9CC8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18012513-0021-0000-0000-00004280EF6B Message-Id: <20180125131455.14466-1-frediz@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-25_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801250179 Subject: [Skiboot] [PATCH] Fix FTBFS with -Werror=format-overflow X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?b?RnLDqWTDqXJpYyBCb25uYXJk?= Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" i2c.c fails to compile with gcc7 and -Werror=format-overflow used in Debian Unstable and Ubuntu 18.04 : i2c.c: In function ‘i2c_init’: i2c.c:211:15: error: ‘%s’ directive writing up to 255 bytes into a region of size 236 [-Werror=format-overflow=] We just make sure we never write more than what the destination can store. Signed-off-by: Frédéric Bonnard --- external/opal-prd/i2c.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/external/opal-prd/i2c.c b/external/opal-prd/i2c.c index ba4b3c85..dca303e4 100644 --- a/external/opal-prd/i2c.c +++ b/external/opal-prd/i2c.c @@ -234,7 +234,13 @@ void i2c_init(void) continue; /* Get bus name */ - sprintf(dpath, SYSFS "/class/i2c-dev/%s/name", devent->d_name); + if (snprintf(dpath, NAME_MAX, SYSFS "/class/i2c-dev/%s/name", + devent->d_name) < 0 ) { + pr_log(LOG_ERR, "I2C: bus name longer than NAME_MAX : " + SYSFS "/class/i2c-dev/%s/name", + devent->d_name); + return; + } f = fopen(dpath, "r"); if (!f) { pr_log(LOG_NOTICE, "I2C: Can't open %s: %m, skipping.",