Skip to content

Commit 1221d49

Browse files
authored
Merge pull request #43 from HuO50/smbios-3.3.0
fix gcc compiling warning info for Smbios 3.3.0
2 parents 9416b89 + e7ed843 commit 1221d49

File tree

5 files changed

+35
-27
lines changed

5 files changed

+35
-27
lines changed

src/dmidecode.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4259,7 +4259,7 @@ void dmi_additional_info(xmlNode *node, const struct dmi_header *h)
42594259
assert( node != NULL );
42604260

42614261
for(i = 0; i < count; i++) {
4262-
xmlNode *data_n = NULL, *str_n = NULL, *val_n = NULL;
4262+
xmlNode *data_n = NULL, *val_n = NULL;
42634263

42644264
/* Check for short entries */
42654265
if(h->length < offset + 1) {
@@ -4277,7 +4277,7 @@ void dmi_additional_info(xmlNode *node, const struct dmi_header *h)
42774277
dmixml_AddAttribute(data_n, "ReferenceHandle", "0x%04x", WORD(p + 0x01));
42784278
dmixml_AddAttribute(data_n, "ReferenceOffset", "0x%02x", p[0x03]);
42794279

4280-
str_n = dmixml_AddDMIstring(data_n, "String", h, p[0x04]);
4280+
dmixml_AddDMIstring(data_n, "String", h, p[0x04]);
42814281

42824282
switch (length - 0x05) {
42834283
case 1:
@@ -4443,9 +4443,9 @@ void dmi_parse_protocol_record(xmlNode *node, u8 *rec)
44434443
u8 assign_val;
44444444
u8 addrtype;
44454445
u8 hlen;
4446-
const char *addrstr;
4446+
// const char *addrstr;
44474447
const char *hname;
4448-
char attr[38];
4448+
// char attr[38];
44494449

44504450
/* DSP0270: 8.5: Protocol Identifier */
44514451
rid = rec[0x0];
@@ -4785,7 +4785,6 @@ void dmi_tpm_characteristics(xmlNode *node, u64 code)
47854785
*/
47864786
if (code.l & (1 << 2)) {
47874787
dmixml_AddTextContent(data_n, "%s", characteristics[0]);
4788-
return data_n;
47894788
}
47904789

47914790
for (i = 3; i <= 5; i++)
@@ -5245,7 +5244,7 @@ xmlNode *dmi_decode(xmlNode *prnt_n, dmi_codes_major *dmiMajor, struct dmi_heade
52455244
dmixml_AddAttribute(sect_n, "Databuswidth", "%i", data[0x11]);
52465245

52475246
if( h->length - 0x13 >= data[0x12] * 5)
5248-
dmi_slot_peers(sect_n, data[0x12], h, data+0x13);
5247+
dmi_slot_peers(sect_n, data[0x12], data+0x13, h);
52495248
break;
52505249

52515250
case 10: /* 7.11 On Board Devices Information */
@@ -6030,7 +6029,7 @@ xmlNode *dmi_decode(xmlNode *prnt_n, dmi_codes_major *dmiMajor, struct dmi_heade
60306029
if (h->length < 0x1B){
60316030
break;
60326031
}
6033-
dmi_tpm_vendor_id(sect_n, data[0x04]);
6032+
dmi_tpm_vendor_id(sect_n, data + 0x04);
60346033
switch (data[0x08]) {
60356034
case 0x01:
60366035
/*
@@ -6271,7 +6270,7 @@ xmlNode *smbios3_decode_get_version(u8 * buf, const char *devmem)
62716270
dmixml_AddAttribute(data_n, "type", "SMBIOS");
62726271

62736272
if(check == 1) {
6274-
u32 ver = (buf[0x07] << 16) + (buf[0x08] << 8) + buf[0x09];
6273+
// u32 ver = (buf[0x07] << 16) + (buf[0x08] << 8) + buf[0x09];
62756274
dmixml_AddTextContent(data_n, "SMBIOS %i.%i.%i present", buf[0x07], buf[0x08], buf[0x09]);
62766275
dmixml_AddAttribute(data_n, "version", "%i.%i.%i", buf[0x07], buf[0x08],buf[0x09]);
62776276
} else if(check == 0) {

src/dmidecodemodule.c

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -144,22 +144,24 @@ xmlNode *dmidecode_get_version(options *opt)
144144
if(opt->dumpfile != NULL) {
145145
//. printf("Reading SMBIOS/DMI data from file %s.\n", dumpfile);
146146
if((buf = mem_chunk(opt->logdata, 0, 0x20, opt->dumpfile)) != NULL) {
147-
ver_n = NULL;
148-
goto exit_free;
149-
}
150-
if(memcmp(buf, "_SM3_", 5) == 0){
151-
ver_n = smbios3_decode_get_version(buf, opt->dumpfile);
152-
if ( dmixml_GetAttrValue(ver_n, "unknown") == NULL )
153-
found++;
154-
} else if(memcmp(buf, "_SM_", 4) == 0) {
155-
ver_n = smbios_decode_get_version(buf, opt->dumpfile);
156-
if( dmixml_GetAttrValue(ver_n, "unknown") == NULL )
157-
found++;
158-
} else if(memcmp(buf, "_DMI_", 5) == 0) {
159-
ver_n = legacy_decode_get_version(buf, opt->dumpfile);
160-
if( dmixml_GetAttrValue(ver_n, "unknown") == NULL )
161-
found++;
147+
if (memcmp(buf, "_SM3_", 5) == 0) {
148+
ver_n = smbios3_decode_get_version(buf, opt->dumpfile);
149+
if (dmixml_GetAttrValue(ver_n, "unknown") == NULL)
150+
found++;
151+
} else if (memcmp(buf, "_SM_", 4) == 0) {
152+
ver_n = smbios_decode_get_version(buf, opt->dumpfile);
153+
if (dmixml_GetAttrValue(ver_n, "unknown") == NULL)
154+
found++;
155+
} else if (memcmp(buf, "_DMI_", 5) == 0) {
156+
ver_n = legacy_decode_get_version(buf, opt->dumpfile);
157+
if (dmixml_GetAttrValue(ver_n, "unknown") == NULL)
158+
found++;
159+
}
160+
} else {
161+
ver_n = NULL;
162+
goto exit_free;
162163
}
164+
163165
}
164166

165167
/*
@@ -201,7 +203,7 @@ xmlNode *dmidecode_get_version(options *opt)
201203
goto exit_free;
202204
}
203205

204-
if(buf = mem_chunk(opt->logdata, fp, 0x20, opt->devmem) == NULL){
206+
if((buf = mem_chunk(opt->logdata, fp, 0x20, opt->devmem)) == NULL){
205207
ver_n = NULL;
206208
goto exit_free;
207209
}
@@ -345,7 +347,7 @@ int dmidecode_get_xml(options *opt, xmlNode* dmixml_n)
345347
goto exit_free;
346348
}
347349

348-
if(buf = mem_chunk(opt->logdata, fp, 0x20, opt->devmem) == NULL ){
350+
if((buf = mem_chunk(opt->logdata, fp, 0x20, opt->devmem)) == NULL ){
349351
ret = 1;
350352
goto exit_free;
351353
}
@@ -390,9 +392,10 @@ int dmidecode_get_xml(options *opt, xmlNode* dmixml_n)
390392
}
391393
} else if(memcmp(buf + fp, "_DMI_", 5) == 0) {
392394
if(legacy_decode(opt->logdata, opt->type,
393-
buf + fp, opt->devmem, 0, dmixml_n))
395+
buf + fp, opt->devmem, 0, dmixml_n)) {
394396
found++;
395397
goto done;
398+
}
396399
}
397400
}
398401
#endif

src/dmidump.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ static int legacy_decode(u8 *buf, const char *devmem, u32 flags, const char *du
154154
memcpy(crafted, buf, 16);
155155
overwrite_smbios3_address(crafted);
156156
write_dump(0, 0x0F, crafted, dumpfile, 1);
157+
158+
return 1;
157159
}
158160

159161
int dump(const char *memdev, const char *dumpfile)

src/efi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ int address_from_efi(Log_t *logp, size_t * address)
8383
log_append(logp, LOGFL_NODUPS, LOG_WARNING, "%s: SMBIOS entry point missing", filename);
8484
}
8585

86+
if(ret == 0){
87+
log_append(logp, LOGFL_NODUPS, LOG_WARNING, "%s: entry point at 0x%08llx", eptype, (unsigned long long)*address);
88+
}
89+
8690
return ret;
8791
}
8892

src/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ void *mem_chunk(Log_t *logp, size_t base, size_t len, const char *devmem)
222222
* mmap() will fail with SIGBUS if trying to map beyond the end of
223223
* the file.
224224
*/
225-
if (sigill_error || S_ISREG(statbuf.st_mode) && base + (off_t)len > statbuf.st_size )
225+
if ((sigill_error || S_ISREG(statbuf.st_mode)) && (__off_t)(base + (off_t)len) > statbuf.st_size )
226226
{
227227
log_append(logp, LOGFL_NORMAL, LOG_WARNING,
228228
"mmap: Can't map beyond end of file %s: %s",

0 commit comments

Comments
 (0)