These patches fix a few compiler warnings. Tested on top of commit aee0dc5565711ef5be7c30fb5fc1c5f3f98db09f Jonathan Boeing (6): Use z width specifier when printing size_t variable pxe: fix truncation warning gpllib: fix sizeof(char *) misuse hdt: fix sizeof(char *) misuse hdt: fix sizeof(char *) misuse hdt: fix sizeof(char *) misuse com32/gpllib/dmi/dmi.c | 24 +++--- com32/hdt/hdt-cli-cpu.c | 178 ++++++++++++++++++++-------------------- com32/hdt/hdt-cli.c | 5 +- com32/hdt/hdt-menu-processor.c | 178 ++++++++++++++++++++-------------------- com32/lib/syslinux/load_linux.c | 2 +- core/fs/pxe/http.c | 2 +- 6 files changed, 196 insertions(+), 193 deletions(-) -- 2.3.0
Jonathan Boeing
2015-Feb-10 03:01 UTC
[syslinux] [PATCH 1/6] Use z width specifier when printing size_t variable
Fixes the warning: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'size_t' Signed-off-by: Jonathan Boeing <jonathan.n.boeing at gmail.com> --- com32/lib/syslinux/load_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com32/lib/syslinux/load_linux.c b/com32/lib/syslinux/load_linux.c index 06ae2a9..042f5a2 100644 --- a/com32/lib/syslinux/load_linux.c +++ b/com32/lib/syslinux/load_linux.c @@ -254,7 +254,7 @@ int bios_boot_linux(void *kernel_buf, size_t kernel_size, cmdline_offset = calc_cmdline_offset(mmap, &hdr, cmdline_size, real_mode_base, real_mode_base + real_mode_size); - dprintf("cmdline_offset at 0x%x\n", real_mode_base + cmdline_offset); + dprintf("cmdline_offset at 0x%zx\n", real_mode_base + cmdline_offset); if (hdr.version < 0x020a) { /* -- 2.3.0
When building efi64, there's a size mismatch between the uint32_t variable (32 bits) and the -1UL (64 bits). This fixes the warning: large integer implicitly truncated to unsigned type Signed-off-by: Jonathan Boeing <jonathan.n.boeing at gmail.com> --- core/fs/pxe/http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/fs/pxe/http.c b/core/fs/pxe/http.c index 0768c10..bd18f3c 100644 --- a/core/fs/pxe/http.c +++ b/core/fs/pxe/http.c @@ -50,7 +50,7 @@ static bool append_ch(char *str, size_t size, size_t *pos, int ch) static size_t cookie_len, header_len; static char *cookie_buf, *header_buf; -__export uint32_t SendCookies = -1UL; /* Send all cookies */ +__export uint32_t SendCookies = UINT_MAX; /* Send all cookies */ static size_t http_do_bake_cookies(char *q) { -- 2.3.0
Jonathan Boeing
2015-Feb-10 03:01 UTC
[syslinux] [PATCH 3/6] gpllib: fix sizeof(char *) misuse
The code was passing sizeof(char *) - not the length of the buffer - to strlcpy and snprintf. Change the function to take the length of the buffer as a parameter. Fixes the warning: argument to 'sizeof' in 'snprintf' call is the same expression as the destination; did you mean to provide an explicit length? Signed-off-by: Jonathan Boeing <jonathan.n.boeing at gmail.com> --- com32/gpllib/dmi/dmi.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/com32/gpllib/dmi/dmi.c b/com32/gpllib/dmi/dmi.c index ef84e1e..5a25b41 100644 --- a/com32/gpllib/dmi/dmi.c +++ b/com32/gpllib/dmi/dmi.c @@ -100,20 +100,20 @@ static const char *dmi_system_reset_boot_option(uint8_t code) return out_of_spec; } -static void dmi_system_reset_count(uint16_t code, char *array) +static void dmi_system_reset_count(uint16_t code, char *array, size_t len) { if (code == 0xFFFF) - strlcpy(array, "Unknown", sizeof array); + strlcpy(array, "Unknown", len); else - snprintf(array, sizeof array, "%u", code); + snprintf(array, len, "%u", code); } -static void dmi_system_reset_timer(uint16_t code, char *array) +static void dmi_system_reset_timer(uint16_t code, char *array, size_t len) { if (code == 0xFFFF) - strlcpy(array, "Unknown", sizeof array); + strlcpy(array, "Unknown", len); else - snprintf(array, sizeof array, "%u min", code); + snprintf(array, len, "%u min", code); } /* @@ -947,13 +947,17 @@ void dmi_decode(struct dmi_header *h, uint16_t ver, s_dmi * dmi) dmi_system_reset_boot_option((data[0x04] >> 3) & 0x3), sizeof dmi->system.system_reset.boot_option_on_limit); dmi_system_reset_count(WORD(data + 0x05), - dmi->system.system_reset.reset_count); + dmi->system.system_reset.reset_count, + sizeof(dmi->system.system_reset.reset_count)); dmi_system_reset_count(WORD(data + 0x07), - dmi->system.system_reset.reset_limit); + dmi->system.system_reset.reset_limit, + sizeof(dmi->system.system_reset.reset_limit)); dmi_system_reset_timer(WORD(data + 0x09), - dmi->system.system_reset.timer_interval); + dmi->system.system_reset.timer_interval, + sizeof(dmi->system.system_reset.timer_interval)); dmi_system_reset_timer(WORD(data + 0x0B), - dmi->system.system_reset.timeout); + dmi->system.system_reset.timeout, + sizeof(dmi->system.system_reset.timeout)); break; case 24: /* 3.3.25 Hardware Security */ if (h->length < 0x05) -- 2.3.0
Jonathan Boeing
2015-Feb-10 03:01 UTC
[syslinux] [PATCH 4/6] hdt: fix sizeof(char *) misuse
The code was passing sizeof(char *) - not the length of the buffer - to memset. Change the function to take the length of the buffer as a parameter. Fixes the warning: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to provide an explicit length? Signed-off-by: Jonathan Boeing <jonathan.n.boeing at gmail.com> --- com32/hdt/hdt-cli-cpu.c | 178 ++++++++++++++++++++++++------------------------ 1 file changed, 89 insertions(+), 89 deletions(-) diff --git a/com32/hdt/hdt-cli-cpu.c b/com32/hdt/hdt-cli-cpu.c index 6d764ce..660a90b 100644 --- a/com32/hdt/hdt-cli-cpu.c +++ b/com32/hdt/hdt-cli-cpu.c @@ -74,7 +74,7 @@ void main_show_cpu(int argc __unused, char **argv __unused, /* Let's compute the cpu flags display * We have to maximize the number of flags per line */ -static void show_flag(char *buffer, bool flag, char *flag_name, bool flush) +static void show_flag(char *buffer, size_t len, bool flag, char *flag_name, bool flush) { char output_buffer[81]; /* Flush is only set when no more flags are present @@ -86,7 +86,7 @@ static void show_flag(char *buffer, bool flag, char *flag_name, bool flush) snprintf(output_buffer, sizeof output_buffer, "Flags : %s\n", buffer); more_printf("%s", output_buffer); - memset(buffer, 0, sizeof(buffer)); + memset(buffer, 0, len); if (flush) return; } @@ -158,95 +158,95 @@ static void show_cpu(int argc __unused, char **argv __unused, /* Let's display the supported cpu flags */ memset(buffer, 0, sizeof(buffer)); - show_flag(buffer, hardware->cpu.flags.fpu, "fpu ", false); - show_flag(buffer, hardware->cpu.flags.vme, "vme ", false); - show_flag(buffer, hardware->cpu.flags.de, "de ", false); - show_flag(buffer, hardware->cpu.flags.pse, "pse ", false); - show_flag(buffer, hardware->cpu.flags.tsc, "tsc ", false); - show_flag(buffer, hardware->cpu.flags.msr, "msr ", false); - show_flag(buffer, hardware->cpu.flags.pae, "pae ", false); - show_flag(buffer, hardware->cpu.flags.mce, "mce ", false); - show_flag(buffer, hardware->cpu.flags.cx8, "cx8 ", false); - show_flag(buffer, hardware->cpu.flags.apic, "apic ", false); - show_flag(buffer, hardware->cpu.flags.sep, "sep ", false); - show_flag(buffer, hardware->cpu.flags.mtrr, "mtrr ", false); - show_flag(buffer, hardware->cpu.flags.pge, "pge ", false); - show_flag(buffer, hardware->cpu.flags.mca, "mca ", false); - show_flag(buffer, hardware->cpu.flags.cmov, "cmov ", false); - show_flag(buffer, hardware->cpu.flags.pat, "pat ", false); - show_flag(buffer, hardware->cpu.flags.pse_36, "pse_36 ", false); - show_flag(buffer, hardware->cpu.flags.psn, "psn ", false); - show_flag(buffer, hardware->cpu.flags.clflsh, "clflsh ", false); - show_flag(buffer, hardware->cpu.flags.dts, "dts ", false); - show_flag(buffer, hardware->cpu.flags.acpi, "acpi ", false); - show_flag(buffer, hardware->cpu.flags.mmx, "mmx ", false); - show_flag(buffer, hardware->cpu.flags.sse, "sse ", false); - show_flag(buffer, hardware->cpu.flags.sse2, "sse2 ", false); - show_flag(buffer, hardware->cpu.flags.ss, "ss ", false); - show_flag(buffer, hardware->cpu.flags.htt, "ht ", false); - show_flag(buffer, hardware->cpu.flags.acc, "acc ", false); - show_flag(buffer, hardware->cpu.flags.syscall, "syscall ", false); - show_flag(buffer, hardware->cpu.flags.mp, "mp ", false); - show_flag(buffer, hardware->cpu.flags.nx, "nx ", false); - show_flag(buffer, hardware->cpu.flags.mmxext, "mmxext ", false); - show_flag(buffer, hardware->cpu.flags.lm, "lm ", false); - show_flag(buffer, hardware->cpu.flags.nowext, "3dnowext ", false); - show_flag(buffer, hardware->cpu.flags.now, "3dnow! ", false); - show_flag(buffer, hardware->cpu.flags.svm, "svm ", false); - show_flag(buffer, hardware->cpu.flags.vmx, "vmx ", false); - show_flag(buffer, hardware->cpu.flags.pbe, "pbe ", false); - show_flag(buffer, hardware->cpu.flags.fxsr_opt, "fxsr_opt ", false); - show_flag(buffer, hardware->cpu.flags.gbpages, "gbpages ", false); - show_flag(buffer, hardware->cpu.flags.rdtscp, "rdtscp ", false); - show_flag(buffer, hardware->cpu.flags.pni, "pni ", false); - show_flag(buffer, hardware->cpu.flags.pclmulqd, "pclmulqd ", false); - show_flag(buffer, hardware->cpu.flags.dtes64, "dtes64 ", false); - show_flag(buffer, hardware->cpu.flags.smx, "smx ", false); - show_flag(buffer, hardware->cpu.flags.est, "est ", false); - show_flag(buffer, hardware->cpu.flags.tm2, "tm2 ", false); - show_flag(buffer, hardware->cpu.flags.sse3, "sse3 ", false); - show_flag(buffer, hardware->cpu.flags.fma, "fma ", false); - show_flag(buffer, hardware->cpu.flags.cx16, "cx16 ", false); - show_flag(buffer, hardware->cpu.flags.xtpr, "xtpr ", false); - show_flag(buffer, hardware->cpu.flags.pdcm, "pdcm ", false); - show_flag(buffer, hardware->cpu.flags.dca, "dca ", false); - show_flag(buffer, hardware->cpu.flags.xmm4_1, "xmm4_1 ", false); - show_flag(buffer, hardware->cpu.flags.xmm4_2, "xmm4_2 ", false); - show_flag(buffer, hardware->cpu.flags.x2apic, "x2apic ", false); - show_flag(buffer, hardware->cpu.flags.movbe, "movbe ", false); - show_flag(buffer, hardware->cpu.flags.popcnt, "popcnt ", false); - show_flag(buffer, hardware->cpu.flags.aes, "aes ", false); - show_flag(buffer, hardware->cpu.flags.xsave, "xsave ", false); - show_flag(buffer, hardware->cpu.flags.osxsave, "osxsave ", false); - show_flag(buffer, hardware->cpu.flags.avx, "avx ", false); - show_flag(buffer, hardware->cpu.flags.hypervisor, "hypervisor ", false); - show_flag(buffer, hardware->cpu.flags.ace2, "ace2 ", false); - show_flag(buffer, hardware->cpu.flags.ace2_en, "ace2_en ", false); - show_flag(buffer, hardware->cpu.flags.phe, "phe ", false); - show_flag(buffer, hardware->cpu.flags.phe_en, "phe_en ", false); - show_flag(buffer, hardware->cpu.flags.pmm, "pmm ", false); - show_flag(buffer, hardware->cpu.flags.pmm_en, "pmm_en ", false); - show_flag(buffer, hardware->cpu.flags.extapic, "extapic ", false); - show_flag(buffer, hardware->cpu.flags.cr8_legacy, "cr8_legacy ", false); - show_flag(buffer, hardware->cpu.flags.abm, "abm ", false); - show_flag(buffer, hardware->cpu.flags.sse4a, "sse4a ", false); - show_flag(buffer, hardware->cpu.flags.misalignsse, "misalignsse ", false); - show_flag(buffer, hardware->cpu.flags.nowprefetch, "3dnowprefetch ", false); - show_flag(buffer, hardware->cpu.flags.osvw, "osvw ", false); - show_flag(buffer, hardware->cpu.flags.ibs, "ibs ", false); - show_flag(buffer, hardware->cpu.flags.sse5, "sse5 ", false); - show_flag(buffer, hardware->cpu.flags.skinit, "skinit ", false); - show_flag(buffer, hardware->cpu.flags.wdt, "wdt ", false); - show_flag(buffer, hardware->cpu.flags.ida, "ida ", false); - show_flag(buffer, hardware->cpu.flags.arat, "arat ", false); - show_flag(buffer, hardware->cpu.flags.tpr_shadow, "tpr_shadow ", false); - show_flag(buffer, hardware->cpu.flags.vnmi, "vnmi ", false); - show_flag(buffer, hardware->cpu.flags.flexpriority, "flexpriority ", false); - show_flag(buffer, hardware->cpu.flags.ept, "ept ", false); - show_flag(buffer, hardware->cpu.flags.vpid, "vpid ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.fpu, "fpu ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.vme, "vme ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.de, "de ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pse, "pse ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.tsc, "tsc ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.msr, "msr ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pae, "pae ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.mce, "mce ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.cx8, "cx8 ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.apic, "apic ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.sep, "sep ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.mtrr, "mtrr ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pge, "pge ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.mca, "mca ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.cmov, "cmov ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pat, "pat ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pse_36, "pse_36 ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.psn, "psn ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.clflsh, "clflsh ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.dts, "dts ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.acpi, "acpi ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.mmx, "mmx ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.sse, "sse ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.sse2, "sse2 ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.ss, "ss ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.htt, "ht ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.acc, "acc ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.syscall, "syscall ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.mp, "mp ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.nx, "nx ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.mmxext, "mmxext ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.lm, "lm ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.nowext, "3dnowext ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.now, "3dnow! ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.svm, "svm ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.vmx, "vmx ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pbe, "pbe ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.fxsr_opt, "fxsr_opt ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.gbpages, "gbpages ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.rdtscp, "rdtscp ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pni, "pni ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pclmulqd, "pclmulqd ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.dtes64, "dtes64 ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.smx, "smx ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.est, "est ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.tm2, "tm2 ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.sse3, "sse3 ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.fma, "fma ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.cx16, "cx16 ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.xtpr, "xtpr ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pdcm, "pdcm ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.dca, "dca ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.xmm4_1, "xmm4_1 ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.xmm4_2, "xmm4_2 ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.x2apic, "x2apic ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.movbe, "movbe ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.popcnt, "popcnt ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.aes, "aes ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.xsave, "xsave ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.osxsave, "osxsave ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.avx, "avx ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.hypervisor, "hypervisor ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.ace2, "ace2 ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.ace2_en, "ace2_en ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.phe, "phe ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.phe_en, "phe_en ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pmm, "pmm ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.pmm_en, "pmm_en ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.extapic, "extapic ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.cr8_legacy, "cr8_legacy ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.abm, "abm ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.sse4a, "sse4a ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.misalignsse, "misalignsse ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.nowprefetch, "3dnowprefetch ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.osvw, "osvw ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.ibs, "ibs ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.sse5, "sse5 ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.skinit, "skinit ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.wdt, "wdt ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.ida, "ida ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.arat, "arat ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.tpr_shadow, "tpr_shadow ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.vnmi, "vnmi ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.flexpriority, "flexpriority ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.ept, "ept ", false); + show_flag(buffer, sizeof(buffer), hardware->cpu.flags.vpid, "vpid ", false); /* No more flags, let's display the remaining flags */ - show_flag(buffer, false, "", true); + show_flag(buffer, sizeof(buffer), false, "", true); } struct cli_module_descr cpu_show_modules = { -- 2.3.0
Jonathan Boeing
2015-Feb-10 03:01 UTC
[syslinux] [PATCH 5/6] hdt: fix sizeof(char *) misuse
The code was passing sizeof(char *) - not the length of the buffer - to memset. Change the function to take the length of the buffer as a parameter. Fixes the warning: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to provide an explicit length? Signed-off-by: Jonathan Boeing <jonathan.n.boeing at gmail.com> --- com32/hdt/hdt-menu-processor.c | 178 ++++++++++++++++++++--------------------- 1 file changed, 89 insertions(+), 89 deletions(-) diff --git a/com32/hdt/hdt-menu-processor.c b/com32/hdt/hdt-menu-processor.c index f28833b..623c3c8 100644 --- a/com32/hdt/hdt-menu-processor.c +++ b/com32/hdt/hdt-menu-processor.c @@ -28,7 +28,7 @@ #include "hdt-menu.h" -static void show_flag(struct s_my_menu *menu, char *buffer, bool flag, +static void show_flag(struct s_my_menu *menu, char *buffer, size_t len, bool flag, char *flag_name, bool flush) { char output_buffer[SUBMENULEN + 1]; @@ -39,7 +39,7 @@ static void show_flag(struct s_my_menu *menu, char *buffer, bool flag, add_item(output_buffer, statbuffer, OPT_INACTIVE, NULL, 0); menu->items_count++; - memset(buffer, 0, sizeof(buffer)); + memset(buffer, 0, len); if (flush) return; } @@ -213,101 +213,101 @@ void compute_processor(struct s_my_menu *menu, struct s_hardware *hardware) menu->items_count++; memset(buffer1, 0, sizeof(buffer1)); - show_flag(menu, buffer1, hardware->cpu.flags.fpu, "fpu ", false); - show_flag(menu, buffer1, hardware->cpu.flags.vme, "vme ", false); - show_flag(menu, buffer1, hardware->cpu.flags.de, "de ", false); - show_flag(menu, buffer1, hardware->cpu.flags.pse, "pse ", false); - show_flag(menu, buffer1, hardware->cpu.flags.tsc, "tsc ", false); - show_flag(menu, buffer1, hardware->cpu.flags.msr, "msr ", false); - show_flag(menu, buffer1, hardware->cpu.flags.pae, "pae ", false); - show_flag(menu, buffer1, hardware->cpu.flags.mce, "mce ", false); - show_flag(menu, buffer1, hardware->cpu.flags.cx8, "cx8 ", false); - show_flag(menu, buffer1, hardware->cpu.flags.apic, "apic ", false); - show_flag(menu, buffer1, hardware->cpu.flags.sep, "sep ", false); - show_flag(menu, buffer1, hardware->cpu.flags.mtrr, "mtrr ", false); - show_flag(menu, buffer1, hardware->cpu.flags.pge, "pge ", false); - show_flag(menu, buffer1, hardware->cpu.flags.mca, "mca ", false); - show_flag(menu, buffer1, hardware->cpu.flags.cmov, "cmov ", false); - show_flag(menu, buffer1, hardware->cpu.flags.pat, "pat ", false); - show_flag(menu, buffer1, hardware->cpu.flags.pse_36, "pse_36 ", false); - show_flag(menu, buffer1, hardware->cpu.flags.psn, "psn ", false); - show_flag(menu, buffer1, hardware->cpu.flags.clflsh, "clflsh ", false); - show_flag(menu, buffer1, hardware->cpu.flags.dts, "dts ", false); - show_flag(menu, buffer1, hardware->cpu.flags.acpi, "acpi ", false); - show_flag(menu, buffer1, hardware->cpu.flags.mmx, "mmx ", false); - show_flag(menu, buffer1, hardware->cpu.flags.sse, "sse ", false); - show_flag(menu, buffer1, hardware->cpu.flags.sse2, "sse2 ", false); - show_flag(menu, buffer1, hardware->cpu.flags.ss, "ss ", false); - show_flag(menu, buffer1, hardware->cpu.flags.htt, "ht ", false); - show_flag(menu, buffer1, hardware->cpu.flags.acc, "acc ", false); - show_flag(menu, buffer1, hardware->cpu.flags.syscall, "syscall ", false); - show_flag(menu, buffer1, hardware->cpu.flags.mp, "mp ", false); - show_flag(menu, buffer1, hardware->cpu.flags.nx, "nx ", false); - show_flag(menu, buffer1, hardware->cpu.flags.mmxext, "mmxext ", false); - show_flag(menu, buffer1, hardware->cpu.flags.lm, "lm ", false); - show_flag(menu, buffer1, hardware->cpu.flags.nowext, "3dnowext ", false); - show_flag(menu, buffer1, hardware->cpu.flags.now, "3dnow! ", false); - show_flag(menu, buffer1, hardware->cpu.flags.svm, "svm ", false); - show_flag(menu, buffer1, hardware->cpu.flags.vmx, "vmx ", false); - show_flag(menu, buffer1, hardware->cpu.flags.pbe, "pbe ", false); - show_flag(menu, buffer1, hardware->cpu.flags.fxsr_opt, "fxsr_opt ", false); - show_flag(menu, buffer1, hardware->cpu.flags.gbpages, "gbpages ", false); - show_flag(menu, buffer1, hardware->cpu.flags.rdtscp, "rdtscp ", false); - show_flag(menu, buffer1, hardware->cpu.flags.pni, "pni ", false); - show_flag(menu, buffer1, hardware->cpu.flags.pclmulqd, "pclmulqd ", false); - show_flag(menu, buffer1, hardware->cpu.flags.dtes64, "dtes64 ", false); - show_flag(menu, buffer1, hardware->cpu.flags.smx, "smx ", false); - show_flag(menu, buffer1, hardware->cpu.flags.est, "est ", false); - show_flag(menu, buffer1, hardware->cpu.flags.tm2, "tm2 ", false); - show_flag(menu, buffer1, hardware->cpu.flags.sse3, "sse3 ", false); - show_flag(menu, buffer1, hardware->cpu.flags.fma, "fma ", false); - show_flag(menu, buffer1, hardware->cpu.flags.cx16, "cx16 ", false); - show_flag(menu, buffer1, hardware->cpu.flags.xtpr, "xtpr ", false); - show_flag(menu, buffer1, hardware->cpu.flags.pdcm, "pdcm ", false); - show_flag(menu, buffer1, hardware->cpu.flags.dca, "dca ", false); - show_flag(menu, buffer1, hardware->cpu.flags.xmm4_1, "xmm4_1 ", false); - show_flag(menu, buffer1, hardware->cpu.flags.xmm4_2, "xmm4_2 ", false); - show_flag(menu, buffer1, hardware->cpu.flags.x2apic, "x2apic ", false); - show_flag(menu, buffer1, hardware->cpu.flags.movbe, "movbe ", false); - show_flag(menu, buffer1, hardware->cpu.flags.popcnt, "popcnt ", false); - show_flag(menu, buffer1, hardware->cpu.flags.aes, "aes ", false); - show_flag(menu, buffer1, hardware->cpu.flags.xsave, "xsave ", false); - show_flag(menu, buffer1, hardware->cpu.flags.osxsave, "osxsave ", false); - show_flag(menu, buffer1, hardware->cpu.flags.avx, "avx ", false); - show_flag(menu, buffer1, hardware->cpu.flags.hypervisor, "hypervisor ", + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.fpu, "fpu ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.vme, "vme ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.de, "de ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pse, "pse ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.tsc, "tsc ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.msr, "msr ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pae, "pae ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.mce, "mce ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.cx8, "cx8 ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.apic, "apic ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.sep, "sep ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.mtrr, "mtrr ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pge, "pge ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.mca, "mca ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.cmov, "cmov ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pat, "pat ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pse_36, "pse_36 ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.psn, "psn ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.clflsh, "clflsh ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.dts, "dts ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.acpi, "acpi ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.mmx, "mmx ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.sse, "sse ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.sse2, "sse2 ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.ss, "ss ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.htt, "ht ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.acc, "acc ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.syscall, "syscall ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.mp, "mp ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.nx, "nx ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.mmxext, "mmxext ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.lm, "lm ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.nowext, "3dnowext ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.now, "3dnow! ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.svm, "svm ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.vmx, "vmx ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pbe, "pbe ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.fxsr_opt, "fxsr_opt ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.gbpages, "gbpages ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.rdtscp, "rdtscp ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pni, "pni ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pclmulqd, "pclmulqd ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.dtes64, "dtes64 ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.smx, "smx ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.est, "est ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.tm2, "tm2 ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.sse3, "sse3 ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.fma, "fma ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.cx16, "cx16 ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.xtpr, "xtpr ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pdcm, "pdcm ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.dca, "dca ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.xmm4_1, "xmm4_1 ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.xmm4_2, "xmm4_2 ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.x2apic, "x2apic ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.movbe, "movbe ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.popcnt, "popcnt ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.aes, "aes ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.xsave, "xsave ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.osxsave, "osxsave ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.avx, "avx ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.hypervisor, "hypervisor ", false); - show_flag(menu, buffer1, hardware->cpu.flags.ace2, "ace2 ", false); - show_flag(menu, buffer1, hardware->cpu.flags.ace2_en, "ace2_en ", false); - show_flag(menu, buffer1, hardware->cpu.flags.phe, "phe ", false); - show_flag(menu, buffer1, hardware->cpu.flags.phe_en, "phe_en ", false); - show_flag(menu, buffer1, hardware->cpu.flags.pmm, "pmm ", false); - show_flag(menu, buffer1, hardware->cpu.flags.pmm_en, "pmm_en ", false); - show_flag(menu, buffer1, hardware->cpu.flags.extapic, "extapic ", false); - show_flag(menu, buffer1, hardware->cpu.flags.cr8_legacy, "cr8_legacy ", + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.ace2, "ace2 ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.ace2_en, "ace2_en ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.phe, "phe ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.phe_en, "phe_en ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pmm, "pmm ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.pmm_en, "pmm_en ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.extapic, "extapic ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.cr8_legacy, "cr8_legacy ", false); - show_flag(menu, buffer1, hardware->cpu.flags.abm, "abm ", false); - show_flag(menu, buffer1, hardware->cpu.flags.sse4a, "sse4a ", false); - show_flag(menu, buffer1, hardware->cpu.flags.misalignsse, "misalignsse ", + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.abm, "abm ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.sse4a, "sse4a ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.misalignsse, "misalignsse ", false); - show_flag(menu, buffer1, hardware->cpu.flags.nowprefetch, "3dnowprefetch ", + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.nowprefetch, "3dnowprefetch ", false); - show_flag(menu, buffer1, hardware->cpu.flags.osvw, "osvw ", false); - show_flag(menu, buffer1, hardware->cpu.flags.ibs, "ibs ", false); - show_flag(menu, buffer1, hardware->cpu.flags.sse5, "sse5 ", false); - show_flag(menu, buffer1, hardware->cpu.flags.skinit, "skinit ", false); - show_flag(menu, buffer1, hardware->cpu.flags.wdt, "wdt ", false); - show_flag(menu, buffer1, hardware->cpu.flags.ida, "ida ", false); - show_flag(menu, buffer1, hardware->cpu.flags.arat, "arat ", false); - show_flag(menu, buffer1, hardware->cpu.flags.tpr_shadow, "tpr_shadow ", + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.osvw, "osvw ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.ibs, "ibs ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.sse5, "sse5 ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.skinit, "skinit ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.wdt, "wdt ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.ida, "ida ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.arat, "arat ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.tpr_shadow, "tpr_shadow ", false); - show_flag(menu, buffer1, hardware->cpu.flags.vnmi, "vnmi ", false); - show_flag(menu, buffer1, hardware->cpu.flags.flexpriority, "flexpriority ", + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.vnmi, "vnmi ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.flexpriority, "flexpriority ", false); - show_flag(menu, buffer1, hardware->cpu.flags.ept, "ept ", false); - show_flag(menu, buffer1, hardware->cpu.flags.vpid, "vpid ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.ept, "ept ", false); + show_flag(menu, buffer1, sizeof(buffer1), hardware->cpu.flags.vpid, "vpid ", false); /* Let's flush the remaining flags */ - show_flag(menu, buffer1, false, "", true); + show_flag(menu, buffer1, sizeof(buffer1), false, "", true); printf("MENU: Processor menu done (%d items)\n", menu->items_count); } -- 2.3.0
Jonathan Boeing
2015-Feb-10 03:01 UTC
[syslinux] [PATCH 6/6] hdt: fix sizeof(char *) misuse
The code was passing sizeof(const char *) - not the length of the string or the size of the buffer - as the length to strncmp(). These two cases don't need the length, so switch to strcmp. Fixes the warning: argument to 'sizeof' in 'strncmp' call is the same expression as the second source; did you mean to provide an explicit length? Signed-off-by: Jonathan Boeing <jonathan.n.boeing at gmail.com> --- com32/hdt/hdt-cli.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c index 2895b13..776c8e8 100644 --- a/com32/hdt/hdt-cli.c +++ b/com32/hdt/hdt-cli.c @@ -211,7 +211,7 @@ cli_mode_t mode_s_to_mode_t(char *name) int i = 0; while (list_modes[i]) { - if (!strncmp(name, list_modes[i]->name, sizeof(list_modes[i]->name))) + if (!strcmp(name, list_modes[i]->name)) break; i++; } @@ -288,8 +288,7 @@ static void expand_aliases(char *line __unused, char **command, char **module, /* Simple aliases mapping a single command to another one */ for (i = 0; i < MAX_ALIASES; i++) { for (j = 0; j < hdt_aliases[i].nb_aliases; j++) { - if (!strncmp(*command, hdt_aliases[i].aliases[j], - sizeof(hdt_aliases[i].aliases[j]))) { + if (!strcmp(*command, hdt_aliases[i].aliases[j])) { dprintf("CLI DEBUG: ALIAS %s ", *command); strlcpy(*command, hdt_aliases[i].command, sizeof(hdt_aliases[i].command) + 1); -- 2.3.0