[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCHv4 3/3] sysinfo: delete unnecessary white space of sysinfo.



sysinfo: delete unnecessary white space of sysinfo.

  * Trim each element and delete null entry of sysinfo by virSkipSpacesBackwards().

This patch is rebased to following Eric's patches.
Eric's 1/3, 2/3 patches do not change.

  http://www.spinics.net/linux/fedora/libvir/msg41063.html

Signed-off-by: Minoru Usui <usui mxm nes nec co jp>
---
 src/util/sysinfo.c |   63 ++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 42 insertions(+), 21 deletions(-)

diff --git a/src/util/sysinfo.c b/src/util/sysinfo.c
index f4edde9..2d38145 100644
--- a/src/util/sysinfo.c
+++ b/src/util/sysinfo.c
@@ -244,77 +244,88 @@ virSysinfoParseProcessor(char *base, virSysinfoDefPtr ret)
         if ((cur = strstr(base, "Socket Designation: ")) != NULL) {
             cur += 20;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((processor->processor_socket_destination = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Type: ")) != NULL) {
             cur += 6;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((processor->processor_type = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Family: ")) != NULL) {
             cur += 8;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((processor->processor_family = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Manufacturer: ")) != NULL) {
             cur += 14;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((processor->processor_manufacturer = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Signature: ")) != NULL) {
             cur += 11;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((processor->processor_signature = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Version: ")) != NULL) {
             cur += 9;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((processor->processor_version = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "External Clock: ")) != NULL) {
             cur += 16;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((processor->processor_external_clock = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Max Speed: ")) != NULL) {
             cur += 11;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((processor->processor_max_speed = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Status: ")) != NULL) {
             cur += 8;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((processor->processor_status = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Serial Number: ")) != NULL) {
             cur += 15;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((processor->processor_serial_number = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Part Number: ")) != NULL) {
             cur += 13;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((processor->processor_part_number = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
@@ -349,70 +360,80 @@ virSysinfoParseMemory(char *base, virSysinfoDefPtr ret)
             if (STREQLEN(cur, "No Module Installed", eol - cur))
                 goto next;
 
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((memory->memory_size = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Form Factor: ")) != NULL) {
             cur += 13;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((memory->memory_form_factor = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Locator: ")) != NULL) {
             cur += 9;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((memory->memory_locator = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Bank Locator: ")) != NULL) {
             cur += 14;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((memory->memory_bank_locator = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Type: ")) != NULL) {
             cur += 6;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((memory->memory_type = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Type Detail: ")) != NULL) {
             cur += 13;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((memory->memory_type_detail = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Speed: ")) != NULL) {
             cur += 7;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((memory->memory_speed = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Manufacturer: ")) != NULL) {
             cur += 14;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((memory->memory_manufacturer = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Serial Number: ")) != NULL) {
             cur += 15;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((memory->memory_serial_number = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
         if ((cur = strstr(base, "Part Number: ")) != NULL) {
             cur += 13;
             eol = strchr(cur, '\n');
-            if ((eol) &&
+            virSkipSpacesBackwards(cur, &eol);
+            if ((eol != cur) &&
                 ((memory->memory_part_number = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
         }
-- 
1.7.1


-- 
Minoru Usui <usui mxm nes nec co jp>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]