From patchwork Sat Nov 30 09:48:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1202688 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::539; helo=mail-ed1-x539.google.com; envelope-from=swupdate+bncbcxploxj6ikrb4xvrdxqkgqe56cxy7y@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="eODsvUdh"; dkim-atps=neutral Received: from mail-ed1-x539.google.com (mail-ed1-x539.google.com [IPv6:2a00:1450:4864:20::539]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47Q65R2v22z9sP3 for ; Sat, 30 Nov 2019 20:48:41 +1100 (AEDT) Received: by mail-ed1-x539.google.com with SMTP id f22sf19051409edj.14 for ; Sat, 30 Nov 2019 01:48:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1575107314; cv=pass; d=google.com; s=arc-20160816; b=I2oz5YLtmjfS7Z0B4WTdDcGHqXQlwcr6AqvogaJ8r5fh2CWJw/BRiF664u3tLG9vig D6X7N6QSgHgGC0DV+uCg7oMVJCDMG4J0DVuqAI2jfw9wyvyvpYW3mFmSHSDY8BeNATZ1 0/gMQxNyHgGg8SgybNXhG7W1l4n2n6DBul62vrM53vY7F/jZPKp9ftC0tMO7gf3UdQae miLjBJsVMpd/NiI0js9CKmdYfVgvIRJ/k8189ZwGlm733+ug12hoPojRA3mUdV5ZAW4Q EOMI+FBHaguD/0almPchWULZaqKhF/iPbbHrHbe9EUMRu/p4HRmeuUGCpbrYnpYfmG+W 5PrQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=z9OZ/qDj57WJY8p0My8FSYRi3G0tQACs3OiLc7lgw/Y=; b=WLtYFuj5ry7lwUsNdIBDLxBwJ+qRvLd5n23zC/1rh3uL0ASU9vIGV0BDYtqpJsVOCZ dqfeVp/Gv0ZNcHCIsCRU9oIo5Gx1yyIpvyngETxz55s+kYzCHYAHpIZnzX1JqSTJgh9Y dB+CrpmGzPx0DR0frgiaZUuE5q9zdOmNSFqT/QfuU0Xjm/OAJzoch2w2RYGCwE0s60bY sq2VGpz7KvO9MdkLskbtBBSn4jHGZbHNP1jH4ZCJTlQlXSeXvdqJxFr3SqSOix0wwGvp x1MiwYBb9/8gjIYX56CxF3fUFJu9RFQqTY4Lhh6AxzC2kEV9gfRDyiOsMQnhOTU5B6H0 kUgQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=z9OZ/qDj57WJY8p0My8FSYRi3G0tQACs3OiLc7lgw/Y=; b=eODsvUdhBdXz6aViAKmHFEl0JrH/c7tpQFqxOutPsAeY9FYl811fxZTMCie6eZ1uEc rucEAF51XEb0u6xH7dWVRtTyzUCj6wnK4JqMFe1lfTYrF/wSYFh1NUKaKaC2NqAwOJT6 Zt+7KVqOCU5psvotGQ1jA5sDzZiLLE/1AqOdSugStANu6UTwGUPKCpJE3anRaQ9O+oef FYKR9O6ivYZzE342O3m4AaNbPj7TWgkWJRAUckPmNWxOVRwiosrfpxn/QyU+WRaBs+ND ckQYUi0dE4aEB1ug5lh05WIDxlztAIH5uZAdLo6f0Fynra0XFtrDECGMuxZZJWkip6G6 bNEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=z9OZ/qDj57WJY8p0My8FSYRi3G0tQACs3OiLc7lgw/Y=; b=aMra5C7jAbxqK9tVkbX8WLcGWV7tqsfUVM8JoZPziuWdZfTbhvvzlQ6zfeBHpl+R+K Wu2w2ak20zEn8ZPyjaOQwE2oMQ2y3IG84tHma5BbGSc7CQbK9NPQsGbcJrPbZd45AHdT kMrJYZFi3QVxZuitPS4oJfOyeaaUvhxBVt6CLHlq6ztDEgH/aGVxGZ8LeEDw6mIWqzr2 LbHK0SOQW3/JBbNIllFvQ+6NOa4XyDEU29reHvPUsNZ5aYzCVAyLnRo6GR9Tsbbld3Cz +9PH0n7S4hrh4L8Wz6Fl6o/DCwrLroGWh0KVXh0hkba1fCMMIPZdi8nDYplZ8mQQiNRD dTsw== Sender: swupdate@googlegroups.com X-Gm-Message-State: APjAAAUwK1U7agXaf0JxwW3BtHg8MdUX1TYBFHvALPOlSjB3foxmlZye Jg89R7SFfPvS3VF/SeIqQ7E= X-Google-Smtp-Source: APXvYqzmgWuOZFTFv4W/uJdML+zuKl7QMMUigx6IIbvu0LTS+QQkDIp85FxGTFUV/7pt1nk6TdGZVg== X-Received: by 2002:a50:f296:: with SMTP id f22mr50739871edm.26.1575107314203; Sat, 30 Nov 2019 01:48:34 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6402:1d83:: with SMTP id dk3ls620389edb.14.gmail; Sat, 30 Nov 2019 01:48:33 -0800 (PST) X-Received: by 2002:a50:de06:: with SMTP id z6mr51210618edk.279.1575107313583; Sat, 30 Nov 2019 01:48:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575107313; cv=none; d=google.com; s=arc-20160816; b=qOkuhUyo0mcQGwdQhKKQmOyvfjevfsqfeWvi8nZ0EHZDEzJNKycmJBw8yyk+BNhzPl K2Ci3fHenckt7WgTRCaB0auAB7gvsdLcL2qd9/CTMM2K1IkmpFpSMYQs80njlMAWBBtx iJCPvf7FP62gqdiFtDm2eFU9CpRX+mi/Ov0A+ww6wD3evFjQ6f2/rtgITcIvhOuR0yl3 soYFWzdvfkLhKDjX6rkv+nR27OkktrCN7XC5/WpMRzJ4m1qglhPRykG0MbTbP+ndf4y9 1XmCyk2mlX502RwSnTwuPT13qLbgQnoYU9w2ciy5E/3eX6vhwkfuZCHzOsRZmaGQCgVp Qvig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=6gyb8QJdPSEeTe2khjN8J3d/GOEvsLiOqWBy5wJ4+Uk=; b=JktpcUrFTDt15H/TAl3E4u0c5qqwKkjZGYGDMbxdE/IPzMt9lIHBxVB/SOKOCCW2E1 lEUakzDhPczh4fjfybllQale7MDuQVXZhy7es1mSpIdrMKmK/jrr/Ax+HfZIY72gfMqi yoIH+CRv73N8l0LcwervxjFHcsCqVOU9rQrqyOuCsb7+1vZOZvp8UHyEUC18yjxKF04w oRiKusQaZ0r7+0N+f36HmkDMbK11qrmCnTaHRChKrz4PD5+Ac6DqvlcteKYZScJ2W+5O JsTQQE1hxmKrnfCvBLclqBxUO/eA9HvN2iv4MZ+Rxw0YfQQ86Hm6PVTfA2BHccPVIvdR QRZg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id m13si1291042edq.4.2019.11.30.01.48.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 30 Nov 2019 01:48:33 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 47Q65F2QDYz1qqkl; Sat, 30 Nov 2019 10:48:33 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 47Q65F2B8dz1qqtj; Sat, 30 Nov 2019 10:48:33 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id OqC3MDHpwuo8; Sat, 30 Nov 2019 10:48:32 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Sat, 30 Nov 2019 10:48:32 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id E6DC545401B4; Sat, 30 Nov 2019 10:48:31 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EaqKp3S58DsK; Sat, 30 Nov 2019 10:48:29 +0100 (CET) Received: from papero.fritz.box (papero.fritz.box [192.168.178.132]) by babic.homelinux.org (Postfix) with ESMTP id 5034A4540065; Sat, 30 Nov 2019 10:48:29 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH] Fix compiler warning Date: Sat, 30 Nov 2019 10:48:22 +0100 Message-Id: <20191130094822.1505-1-sbabic@denx.de> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , libubootenv/src/uboot_env.c: In function ‘fileprotect’: libubootenv/src/uboot_env.c:557:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result] write(fd_force_ro, &c_unprot_char, 1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libubootenv/src/uboot_env.c:560:3: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result] write(fd_force_ro, &c_prot_char, 1); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ libubootenv/src/uboot_env.c: In function ‘check_env_device.isra.4’: libubootenv/src/uboot_env.c:44:30: warning: ‘__builtin___sprintf_chk’ may write a terminating nul past the end of the destination [-Wformat-overflow=] #define SYS_UBI_VOLUME_NAME "/sys/class/ubi/ubi%d/ubi%d_%d/name" ^ libubootenv/src/uboot_env.c:44:30: note: in definition of macro ‘SYS_UBI_VOLUME_NAME’ #define SYS_UBI_VOLUME_NAME "/sys/class/ubi/ubi%d/ubi%d_%d/name" ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/stdio.h:862:0, from libubootenv/src/uboot_env.c:17: /usr/include/x86_64-linux-gnu/bits/stdio2.h:33:10: note: ‘__builtin___sprintf_chk’ output between 32 and 61 bytes into a destination of size 40 return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ __bos (__s), __fmt, __va_arg_pack ()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Stefano Babic --- src/uboot_env.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/uboot_env.c b/src/uboot_env.c index 0f33931..15e0993 100644 --- a/src/uboot_env.c +++ b/src/uboot_env.c @@ -182,7 +182,7 @@ static int ubi_get_num_volume(char *device) if (dev_id < 0) return -1; - sprintf(filename, SYS_UBI_VOLUME_COUNT, dev_id); + snprintf(filename, sizeof(filename), SYS_UBI_VOLUME_COUNT, dev_id); fd = open(filename, O_RDONLY); if (fd < 0) return -1; @@ -201,7 +201,7 @@ out: static int ubi_get_volume_name(char *device, int vol_id, char vol_name[DEVNAME_MAX_LENGTH]) { - char filename[DEVNAME_MAX_LENGTH]; + char filename[80]; char data[DEVNAME_MAX_LENGTH]; int dev_id, fd, n, ret = -1; @@ -209,7 +209,7 @@ static int ubi_get_volume_name(char *device, int vol_id, char vol_name[DEVNAME_M if (dev_id < 0) return -1; - sprintf(filename, SYS_UBI_VOLUME_NAME, dev_id, dev_id, vol_id); + snprintf(filename, sizeof(filename), SYS_UBI_VOLUME_NAME, dev_id, dev_id, vol_id); fd = open(filename, O_RDONLY); if (fd < 0) return -1; @@ -554,10 +554,10 @@ static int fileprotect(struct uboot_flash_env *dev, bool on) } if(on == false){ - write(fd_force_ro, &c_unprot_char, 1); + ret_int = write(fd_force_ro, &c_unprot_char, 1); } else { fsync(dev->fd); - write(fd_force_ro, &c_prot_char, 1); + ret_int = write(fd_force_ro, &c_prot_char, 1); } close(fd_force_ro);