[libvirt] [PATCHv2 5/5] S390: Added sysinfo for host on s390x.

Michal Privoznik mprivozn at redhat.com
Mon Jun 25 14:42:40 UTC 2012


On 25.06.2012 13:29, Daniel P. Berrange wrote:
> On Fri, Jun 22, 2012 at 01:50:14PM +0200, Viktor Mihajlovski wrote:
> 
>> +static int
>> +virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret)
>> +{
> 
>> +    /* Find processor N: line and gather the processor manufacturer, version, serial number, and family */

Line too long.

>> +    while((tmp_base = strstr(base, "processor ")) != NULL) {
> 
> Missing space after 'while'
> 
> 
>> +/* virSysinfoRead for s390x
>> + * Gathers sysinfo data from /proc/sysinfo and /proc/cpuinfo */
>> +virSysinfoDefPtr
>> +virSysinfoRead(void) {
>> +    virSysinfoDefPtr ret = NULL;
>> +    char *outbuf = NULL;
>> +
>> +    if (VIR_ALLOC(ret) < 0)
>> +        goto no_memory;
>> +
>> +    /* Gather info from /proc/cpuinfo */
>> +    if(virFileReadAll(CPUINFO, 2048, &outbuf) < 0) {
> 
> Missing space after 'if'
> 
>> +        virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
>> +                             _("Failed to open %s"), CPUINFO);
>> +        return NULL;
>> +    }
>> +
>> +    ret->nprocessor = 0;
>> +    ret->processor = NULL;
>> +    if (virSysinfoParseProcessor(outbuf, ret) < 0)
>> +        goto no_memory;
>> +
>> +    /* Free buffer before reading next file */
>> +    VIR_FREE(outbuf);
>> +
>> +    /* Gather info from /proc/sysinfo */
>> +    if(virFileReadAll(SYSINFO, 4096, &outbuf) < 0) {
> 
> Missing space
> 
>> +              virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
>> +                                   _("Failed to open %s"), SYSINFO);
>> +              return NULL;
>> +       }
> 
> Messed up indentation.
> 
>> +
>> +    if (virSysinfoParseSystem(outbuf, ret) < 0)
>> +        goto no_memory;
>> +
>> +    return ret;
>> +
>> +no_memory:
>> +    VIR_FREE(outbuf);
>> +    return NULL;
>> +}
>> +
>>  #elif defined(WIN32) || \
>>      !(defined(__x86_64__) || \
>>        defined(__i386__) ||   \
> 
> 
> ACK with the whitespace fixes
> 
> Daniel
> 

Fixed and pushed now.
Changes I've made:
diff --git a/src/util/sysinfo.c b/src/util/sysinfo.c
index 01cce98..20482db 100644
--- a/src/util/sysinfo.c
+++ b/src/util/sysinfo.c
@@ -307,8 +307,9 @@ virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret)
         manufacturer = (char *) tmp;
     }
 
-    /* Find processor N: line and gather the processor manufacturer, version, serial number, and family */
-    while((tmp_base = strstr(base, "processor ")) != NULL) {
+    /* Find processor N: line and gather the processor manufacturer, version,
+     * serial number, and family */
+    while ((tmp_base = strstr(base, "processor ")) != NULL) {
         base = tmp_base;
         eol = strchr(base, '\n');
         cur = strchr(base, ':') + 1;
@@ -364,7 +365,7 @@ virSysinfoRead(void) {
         goto no_memory;
 
     /* Gather info from /proc/cpuinfo */
-    if(virFileReadAll(CPUINFO, 2048, &outbuf) < 0) {
+    if (virFileReadAll(CPUINFO, 2048, &outbuf) < 0) {
         virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
                              _("Failed to open %s"), CPUINFO);
         return NULL;
@@ -379,11 +380,11 @@ virSysinfoRead(void) {
     VIR_FREE(outbuf);
 
     /* Gather info from /proc/sysinfo */
-    if(virFileReadAll(SYSINFO, 4096, &outbuf) < 0) {
-              virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
-                                   _("Failed to open %s"), SYSINFO);
-              return NULL;
-       }
+    if (virFileReadAll(SYSINFO, 4096, &outbuf) < 0) {
+        virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
+                             _("Failed to open %s"), SYSINFO);
+        return NULL;
+    }
 
     if (virSysinfoParseSystem(outbuf, ret) < 0)
         goto no_memory;





Michal




More information about the libvir-list mailing list