WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] tools/firmware/hvmloader/smbios.c::hvm_write_smbios_tables(

To: "List: Xen Developers" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] tools/firmware/hvmloader/smbios.c::hvm_write_smbios_tables()
From: "Jun Koi" <junkoi2004@xxxxxxxxx>
Date: Fri, 7 Dec 2007 17:37:55 +0900
Delivery-date: Fri, 07 Dec 2007 00:38:32 -0800
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=nvMcBB+CuvwW/WeYsxzIUHjqx0Ea4p18yE06JYil3Bk=; b=oz3ObDH+eFS23tZ584JrozqBxGI+I2hKr/0y3J8J52j9ubv2gjOH9jv8MdHQRGbKXMF5JLV6IkpMqKQzh/NwVe7XTsnY8Xlfj5vbX/Xtrm+1kOinDuFocYqgX+1JJ+1I5g+Xj6ZDJGwwaaMWty+iaGyzeopvx2+/bFTOlIJlS6k=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=SJVmHvhTbMK47qU+JE0yv14IRQXkMkKcRS2xD9F6a5SE5Xoz3z+Dbg5Q151tA+YebBWsT4gEvBTVZm7af4Tm6nN/Ss5ZciZqdSq6qCg5GNPFseNGL5LUoZRMFmHOaUrDZsLYhM3botxAdWvkYVuYAYKe+WN5g0Klt//OxYCyS00=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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