Skip to contentSkip to conversation

fix libxc warnings

PATCH New Charles Coffing 1 participant 1 message Mar 2, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix libxc warnings

With gcc 4.1 / glibc 2.3.90, I'm seeing fatal warnings building libxc.

xc_core.c: In function 'xc_domain_dumpcore':
xc_core.c:74: warning: ignoring return value of 'write', declared with attribute warn_unused_result
xc_core.c:75: warning: ignoring return value of 'write', declared with attribute warn_unused_result
xc_core.c:85: warning: ignoring return value of 'write', declared with attribute warn_unused_result

Attached is a trival patch to fix the warnings.

tools/libxc/xc_core.c +11 -3
Index: xen-unstable/tools/libxc/xc_core.c
===================================================================
@@ -71,8 +71,12 @@ xc_domain_dumpcore(int xc_handle,
                                          (sizeof(vcpu_guest_context_t) * nr_vcpus) +
                                          (nr_pages * sizeof(unsigned long)));
 
-    write(dump_fd, &header, sizeof(struct xc_core_header));
-    write(dump_fd, &ctxt, sizeof(ctxt[0]) * nr_vcpus);
+    if (write(dump_fd, &header, sizeof(struct xc_core_header)) < 0 ||
+        write(dump_fd, &ctxt, sizeof(ctxt[0]) * nr_vcpus) < 0)
+    {
+        PERROR("write failed");
+        goto error_out;
+    }
 
     if ((page_array = malloc(nr_pages * sizeof(unsigned long))) == NULL) {
         printf("Could not allocate memory\n");
@@ -82,7 +86,11 @@ xc_domain_dumpcore(int xc_handle,
         printf("Could not get the page frame list\n");
         goto error_out;
     }
-    write(dump_fd, page_array, nr_pages * sizeof(unsigned long));
+    if (write(dump_fd, page_array, nr_pages * sizeof(unsigned long)) < 0)
+    {
+        PERROR("write failed");
+        goto error_out;
+    }
     lseek(dump_fd, header.xch_pages_offset, SEEK_SET);
     for (dump_mem = dump_mem_start, i = 0; i < nr_pages; i++) {
         copy_from_domain_page(xc_handle, domid, page_array, i, dump_mem);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel