aboutsummaryrefslogtreecommitdiffstats
path: root/com32
diff options
context:
space:
mode:
authorJonathan Boeing <jonathan.n.boeing@gmail.com>2015-02-09 20:01:37 -0700
committerGene Cumm <gene.cumm@gmail.com>2015-05-03 10:51:03 -0400
commit82f9527f9e54ae83ff8ce11a82fab2e1b2ac6085 (patch)
tree5eb93e2d6a8ce472169d204e8c407140f8cd3309 /com32
parent1361dd215ff3d303c8ae9e7598ef3ef91bd21d0a (diff)
downloadsyslinux-82f9527f9e54ae83ff8ce11a82fab2e1b2ac6085.tar.gz
syslinux-82f9527f9e54ae83ff8ce11a82fab2e1b2ac6085.tar.xz
syslinux-82f9527f9e54ae83ff8ce11a82fab2e1b2ac6085.zip
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@gmail.com>
Diffstat (limited to 'com32')
-rw-r--r--com32/hdt/hdt-cli-cpu.c178
1 files changed, 89 insertions, 89 deletions
diff --git a/com32/hdt/hdt-cli-cpu.c b/com32/hdt/hdt-cli-cpu.c
index 6d764ce2..660a90b1 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 = {