Message ID | 1498584945-9701-3-git-send-email-marmarek@invisiblethingslab.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Jun 27, 2017 at 07:35:44PM +0200, Marek Marczykowski-Górecki wrote: > 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 <marmarek@invisiblethingslab.com> I think this is fixed in staging by enlarging the size of the buffers. Have you tried the latest code?
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,
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 <marmarek@invisiblethingslab.com> --- tools/xenpmd/xenpmd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)