[PATCH 7/7] dmi: dmicheck: fix a couple of cppcheck style warnings
Colin King
colin.king at canonical.com
Wed Oct 19 13:26:39 UTC 2016
From: Colin Ian King <colin.king at canonical.com>
reduce the scope of some local variables. Do not initialize
struct_type = 0 as it gets set a little while later. Change the
while (1) loop to the fwts for (;;) idoim.
Cleans up cppcheck style warnings:
src/dmi/dmicheck/dmicheck.c:452]: (style) The scope of the variable
'dmi_entry_length' can be reduced.
src/dmi/dmicheck/dmicheck.c:599]: (style) The scope of the variable
'struct_length' can be reduced.
src/dmi/dmicheck/dmicheck.c:600]: (style) The scope of the variable
'struct_type' can be reduced.
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
src/dmi/dmicheck/dmicheck.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/dmi/dmicheck/dmicheck.c b/src/dmi/dmicheck/dmicheck.c
index 51ccd26..1934ebe 100644
--- a/src/dmi/dmicheck/dmicheck.c
+++ b/src/dmi/dmicheck/dmicheck.c
@@ -449,7 +449,6 @@ static void dmi_dump_entry30(fwts_framework *fw, fwts_smbios30_entry *entry)
static int dmi_sane(fwts_framework *fw, fwts_smbios_entry *entry)
{
uint8_t *table, *ptr;
- uint8_t dmi_entry_length;
uint8_t dmi_entry_type = 0;
uint16_t i = 0;
uint16_t table_length = entry->struct_table_length;
@@ -460,6 +459,8 @@ static int dmi_sane(fwts_framework *fw, fwts_smbios_entry *entry)
return FWTS_ERROR;
for (i = 0; i < entry->number_smbios_structures; i++) {
+ uint8_t dmi_entry_length;
+
if (ptr > table + table_length) {
fwts_failed(fw, LOG_LEVEL_MEDIUM,
"SMBIOSTableLengthTooSmall",
@@ -596,8 +597,6 @@ static int smbios_entry_check(fwts_framework *fw)
static int dmi_smbios30_sane(fwts_framework *fw, fwts_smbios30_entry *entry)
{
uint8_t *table, *ptr;
- uint8_t struct_length;
- uint8_t struct_type = 0;
uint16_t i = 0;
uint32_t table_length = entry->struct_table_max_size;
int ret = FWTS_OK;
@@ -606,8 +605,10 @@ static int dmi_smbios30_sane(fwts_framework *fw, fwts_smbios30_entry *entry)
if (table == NULL)
return FWTS_ERROR;
- while (1)
- {
+ for (;;) {
+ uint8_t struct_length;
+ uint8_t struct_type;
+
if (ptr > table + table_length) {
fwts_failed(fw, LOG_LEVEL_MEDIUM,
"SMBIOS30TableLengthTooSmall",
--
2.9.3
More information about the fwts-devel
mailing list