[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] tools/firmware/hvmloader/smbios.c::hvm_write_smbios_tables()
The function hvm_write_smbios_tables() in tools/firmware/hvmloader/smbios.c looks complicated in unnecessary way to me. Part of it like this: ... /* build up human-readable Xen version string */ p = xen_version_str; len = 0; itoa(tmp, xen_major_version); tmp_len = strlen(tmp); len += tmp_len; if ( len >= sizeof(xen_version_str) ) goto error_out; strcpy(p, tmp); p += tmp_len; len++; if ( len >= sizeof(xen_version_str) ) goto error_out; *p = '.'; p++; itoa(tmp, xen_minor_version); tmp_len = strlen(tmp); len += tmp_len; if ( len >= sizeof(xen_version_str) ) goto error_out; strcpy(p, tmp); p += tmp_len; tmp_len = strlen(xen_extra_version); len += tmp_len; if ( len >= sizeof(xen_version_str) ) goto error_out; strcpy(p, xen_extra_version); p += tmp_len; xen_version_str[sizeof(xen_version_str)-1] = '\0'; .... Basically, these long code can be written in only 1 line, like this: snprintf(xen_version_str, sizeof(xen_version_str), "%u.%u%s", xen_major_version, xen_minor_version, xen_extra_verison); (This is from xen-3.1 source code) Thanks, Jun _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |