[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2 1/1] hvmloader: add SMBIOS type 2 info for customized string
>>> On 28.03.19 at 10:05, <talons.lee@xxxxxxxxx> wrote: > --- a/tools/firmware/hvmloader/smbios.c > +++ b/tools/firmware/hvmloader/smbios.c > @@ -497,9 +497,11 @@ static void * > smbios_type_2_init(void *start) > { > struct smbios_type_2 *p = (struct smbios_type_2 *)start; > + const char *s; > uint8_t *ptr; > void *pts; > uint32_t length; > + uint32_t counter = 0; I think this wants to be unsigned int. > @@ -518,8 +520,71 @@ smbios_type_2_init(void *start) > return (start + length); > } > > - /* Only present when passed in */ > - return start; > + memset(p, 0, sizeof(*p)); > + p->header.type = 2; > + p->header.length = sizeof(struct smbios_type_2); > + p->header.handle = SMBIOS_HANDLE_TYPE2; > + p->feature_flags = 0x09; /* Board is a hosting board and replaceable */ > + p->chassis_handle = SMBIOS_HANDLE_TYPE3; > + p->board_type = 0x0a; /* Motherboard */ > + start += sizeof(struct smbios_type_2); sizeof(*p) (also below) please. > + s = xenstore_read(HVM_XS_BASEBOARD_MANUFACTURER, NULL); > + if ( (s != NULL) && (*s != '\0') ) > + { > + strcpy(start, s); > + start += strlen(s) + 1; > + p->manufacturer_str = ++counter; > + } > + > + s = xenstore_read(HVM_XS_BASEBOARD_PRODUCT_NAME, NULL); > + if ( (s != NULL) && (*s != '\0') ) > + { > + strcpy(start, s); > + start += strlen(s) + 1; > + p->product_name_str = ++counter; > + } > + > + s = xenstore_read(HVM_XS_BASEBOARD_VERSION, NULL); > + if ( (s != NULL) && (*s != '\0') ) > + { > + strcpy(start, s); > + start += strlen(s) + 1; > + p->version_str = ++counter; > + } > + > + s = xenstore_read(HVM_XS_BASEBOARD_SERIAL_NUMBER, NULL); > + if ( (s != NULL) && (*s != '\0') ) > + { > + strcpy(start, s); > + start += strlen(s) + 1; > + p->serial_number_str = ++counter; > + } > + > + s = xenstore_read(HVM_XS_BASEBOARD_ASSET_TAG, NULL); > + if ( (s != NULL) && (*s != '\0') ) > + { > + strcpy(start, s); > + start += strlen(s) + 1; > + p->asset_tag_str = ++counter; > + } > + > + s = xenstore_read(HVM_XS_BASEBOARD_LOCATION_IN_CHASSIS, NULL); > + if ( (s != NULL) && (*s != '\0') ) > + { > + strcpy(start, s); > + start += strlen(s) + 1; > + p->location_in_chassis_str = ++counter; > + } > + > + if ( counter ) > + { > + *((uint8_t *)start) = 0; > + return (start + 1); > + } > + else > + /* Only present when passed in or with customized string */ > + return (start - sizeof(struct smbios_type_2)); This will work, but is slightly more cumbersome to read than if you simply used a local variable and kept "start" unchanged. If the local variable was of "char *" type, you could also avoid the uint8_t * cast above. And I think there are a number of unnecessary parentheses in these last few lines. The "else" is unnecessary as well. If you don't want to go the route of a separate local variable, then with the cosmetic issues fixed this patch can have my Acked-by: Jan Beulich <jbeulich@xxxxxxxx> right away, and these cosmetic adjustments could be done while committing. But please let me know whether to wait for a v3 instead. Jan _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |