]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix build breakage in gdb/xml-support.c
authorPedro Alves <palves@redhat.com>
Thu, 19 Oct 2017 17:12:03 +0000 (18:12 +0100)
committerPedro Alves <palves@redhat.com>
Thu, 19 Oct 2017 17:12:03 +0000 (18:12 +0100)
The buildbots are showing that the previous change to
xml_fetch_content_from_file causes __wur warnings/errors:

  ../../binutils-gdb/gdb/xml-support.c: In function gdb::unique_xmalloc_ptr<char> xml_fetch_content_from_file(const char*, void*):
  ../../binutils-gdb/gdb/xml-support.c:1028:43: error: ignoring return value of size_t fread(void*, size_t, size_t, FILE*), declared with attribute warn_unused_result [-Werror=unused-result]
     fread (text.get (), 1, len, file.get ());
     ^

This commit fixes it.

gdb/ChangeLog:
2017-10-19  Pedro Alves  <palves@redhat.com>

* xml-support.c (xml_fetch_content_from_file): Check fread's
return.

gdb/ChangeLog
gdb/xml-support.c

index 6625a03f5d492075eaffd72b728116a6d0da8d06..aaf04850482263e9c331ddcd9ccd046abc900c74 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-19  Pedro Alves  <palves@redhat.com>
+
+       * xml-support.c (xml_fetch_content_from_file): Check fread's
+       return.
+
 2017-10-19  Pedro Alves  <palves@redhat.com>
 
        * ser-base.c (ser_base_read_error_fd): Delete the file handler if
index 1f53d7af54c48af9d37da669f21d0186e2a43b67..2b59180c92c868868d0b4e380d0ec7347c0511f6 100644 (file)
@@ -1025,8 +1025,8 @@ xml_fetch_content_from_file (const char *filename, void *baton)
 
   gdb::unique_xmalloc_ptr<char> text ((char *) xmalloc (len + 1));
 
-  fread (text.get (), 1, len, file.get ());
-  if (ferror (file.get ()))
+  if (fread (text.get (), 1, len, file.get ()) != len
+      || ferror (file.get ()))
     {
       warning (_("Read error from \"%s\""), filename);
       return NULL;