[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v3] tools: fix several "format-truncation" warnings with GCC 7
On 06/20/2017 12:02 PM, Wei Liu wrote: On Tue, Jun 20, 2017 at 11:58:53AM +0100, Julien Grall wrote:Hi Wei, On 06/19/2017 12:39 PM, Wei Liu wrote:On Wed, Jun 14, 2017 at 09:11:48AM +0800, Zhongze Liu wrote:GCC 7.1.1 complains that several buffers passed to snprintf() in xenpmd and tools/ocmal/xc are too small to hold the largest possible resulting string, which is calculated by adding up the maximum length of all the substrings. The warnings are treated as errors by -Werror, and goes like this (abbreviated): xenpmd.c:94:36: error: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 13 [-Werror=format-truncation=] #define BATTERY_INFO_FILE_PATH "/proc/acpi/battery/%s/info" ^ xenpmd.c:113:13: note: ‘snprintf’ output between 25 and 280 bytes into a destination of size 32 xenpmd.c:95:37: error: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 13 [-Werror=format-truncation=] #define BATTERY_STATE_FILE_PATH "/proc/acpi/battery/%s/state" ^ xenpmd.c:116:13: note: ‘snprintf’ output between 26 and 281 bytes into a destination of size 32 xenctrl_stubs.c:65:15: error: ‘%s’ directive output may be truncated writing up to 1023 bytes into a region of size 252 [-Werror=format-truncation=] "%d: %s: %s", error->code, ^~ xenctrl_stubs.c:64:4: note: ‘snprintf’ output 5 or more bytes (assuming 1028) into a destination of size 256 Enlarge the size of these buffers as suggested by the complier (and slightly rounded) to fix the warnings. No functional changes. Signed-off-by: Zhongze Liu <blackskygg@xxxxxxxxx> Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>Applied. Julien, consider this for 4.9?Looking quickly at the patch, it sounds a bit strange to allocate 1028 bytes on the stack. It is more than 1/8 of default stack in Linux (8K). Are we sure the stack will never explode?The default stack size is 8M, not 8K so we it be fine. Sorry I misread the unit. Release-acked-by: Julien Grall <julien.grall@xxxxxxx> Cheers, -- Julien Grall _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |