From patchwork Tue Jun 27 17:35:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= X-Patchwork-Id: 9812873 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1DCC960351 for ; Tue, 27 Jun 2017 17:38:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB55C2866A for ; Tue, 27 Jun 2017 17:38:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFD8B2870C; Tue, 27 Jun 2017 17:38:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 87340286D7 for ; Tue, 27 Jun 2017 17:38:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dPuOt-0001rr-Hn; Tue, 27 Jun 2017 17:35:43 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dPuOs-0001rC-J0 for xen-devel@lists.xen.org; Tue, 27 Jun 2017 17:35:42 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id 67/BC-03696-D6792595; Tue, 27 Jun 2017 17:35:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKIsWRWlGSWpSXmKPExsXilM8irZs7PSj S4MY3QYslHxezODB6HN39mymAMYo1My8pvyKBNePsqRtsBf84KxrWLmVtYLzJ0cXIxSEksIpR YlnvAZYuRk4gJ1uiqXkWE4jNIjCJVaLpFjeILSHgKfH/61NGCNtZ4lP7BXaI5kOMEgfWT2cGS bAJhEq0b5/BCmKLCEhLXPt8mRGkiFlgLqPEjA0f2UASwgJOEru+XmOH2KAq8fD+SaDNHBy8An 4S7Xf0IBbISdw81wk2k1PAX2LX9H9MEMf5SWyctQ9sPq+AoMTJmU/AWpkF1CXWzxMCCfMLKEl sW38Z7E5mAXmJ5q2zmScwCs9C0jELoWMWkqoFjMyrGDWKU4vKUot0jQ30kooy0zNKchMzc3QN Dcz0clOLixPTU3MSk4r1kvNzNzECg5wBCHYw/l0beIhRkoNJSZT3VGdQpBBfUn5KZUZicUZ8U WlOavEhRhkODiUJ3kdTgXKCRanpqRVpmTnAeINJS3DwKInwloKkeYsLEnOLM9MhUqcYdTk2rF 7/hUmIJS8/L1VKnNd+GlCRAEhRRmke3AhY7F9ilJUS5mUEOkqIpyC1KDezBFX+FaM4B6OSMK8 FyCqezLwSuE2vgI5gAjqCZV4AyBEliQgpqQbGwMRnF0x/W2v0fClmZev9y/DUgz3rdnFzX4gs p9AWLy1WZqfPe2Wkrrq+4z2TnsWWFRcnY3xV+/zO4IY7673+/RZakuR0+kLeoXgXruN7rdXOH 32y4GvLdIEDnOlCrbN3bO37oMAl+a476WNV+bu5rxwcp80NaWAJquy99OvQ5Hk6kTP97mxWYi nOSDTUYi4qTgQAHg+t/fgCAAA= X-Env-Sender: marmarek@invisiblethingslab.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1498584940!70042752!1 X-Originating-IP: [66.111.4.27] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTExLjQuMjcgPT4gODQ2Mw==\n X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 47315 invoked from network); 27 Jun 2017 17:35:41 -0000 Received: from out3-smtp.messagingengine.com (HELO out3-smtp.messagingengine.com) (66.111.4.27) by server-13.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 27 Jun 2017 17:35:41 -0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 68AC522015; Tue, 27 Jun 2017 13:35:40 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute7.internal (MEProxy); Tue, 27 Jun 2017 13:35:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=UuL144SaH+e2DCNXSDiPGt8N9ohtm8Hx3x0dTkE6nN0=; b=j0HHThei M8CrbU2K+VpnMU6cD7yXqgUp9h4TPQd6hnLyTRBpr6RzIsroghFzJuI3Qb4W4GU6 swwgzVe1sRqCzEtsR5ZrTRCMvc4LmM1Gw89F2IaOe7L0KP/WZYeBo0oODtq709+f l3NobMhpsxy975oLjwlL2eDTSdsxSvnANLK7glKc1BfKxJ7GTXq7Zg7ghnsG8gyx tBwwPV+AcypWId4nNWKN7CnJzoxzwj1Sp5RIc+rQXEZN0cUN4xLCvF/RwFAQEPB2 xgRLwVO+iaSWmhwtEIcILAlEVx40ebqpM5jhDELhwlQ13agvWhG164u5qJn/djSa Kv1m3XmJXu3KFA== X-ME-Sender: X-Sasl-enc: qske4ur7mKEC4ztiLZolPxwp8wrQVCnEDO8PCgI+I1wx 1498584939 Received: from devel-3rdparty.localdomain (89-70-103-23.dynamic.chello.pl [89.70.103.23]) by mail.messagingengine.com (Postfix) with ESMTPA id 7401524009; Tue, 27 Jun 2017 13:35:39 -0400 (EDT) From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xen.org Date: Tue, 27 Jun 2017 19:35:44 +0200 Message-Id: <1498584945-9701-3-git-send-email-marmarek@invisiblethingslab.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498584945-9701-1-git-send-email-marmarek@invisiblethingslab.com> References: <1498584945-9701-1-git-send-email-marmarek@invisiblethingslab.com> MIME-Version: 1.0 Organization: Invisible Things Lab Cc: Wei Liu , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Subject: [Xen-devel] [PATCH 2/3] tools/xenpmd: fix potential string truncation X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP GCC 7 warns (and thanks to -Werror, fails) about potential string truncation by snprintf in get_next_battery_file. Since the code already check if string is no longer than 4 chars, tell gcc about it. Signed-off-by: Marek Marczykowski-Górecki --- tools/xenpmd/xenpmd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/xenpmd/xenpmd.c b/tools/xenpmd/xenpmd.c index b3a3106..ed6635b 100644 --- a/tools/xenpmd/xenpmd.c +++ b/tools/xenpmd/xenpmd.c @@ -87,12 +87,12 @@ static struct xs_handle *xs; #ifdef RUN_IN_SIMULATE_MODE #define BATTERY_DIR_PATH "/tmp/battery" - #define BATTERY_INFO_FILE_PATH "/tmp/battery/%s/info" - #define BATTERY_STATE_FILE_PATH "/tmp/battery/%s/state" + #define BATTERY_INFO_FILE_PATH "/tmp/battery/%.4s/info" + #define BATTERY_STATE_FILE_PATH "/tmp/battery/%.4s/state" #else #define BATTERY_DIR_PATH "/proc/acpi/battery" - #define BATTERY_INFO_FILE_PATH "/proc/acpi/battery/%s/info" - #define BATTERY_STATE_FILE_PATH "/proc/acpi/battery/%s/state" + #define BATTERY_INFO_FILE_PATH "/proc/acpi/battery/%.4s/info" + #define BATTERY_STATE_FILE_PATH "/proc/acpi/battery/%.4s/state" #endif FILE *get_next_battery_file(DIR *battery_dir,