This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] make rebuffer_line () return void


From: Trevor Saunders <tbsaunde@tbsaunde.org>

Hi,

It only has one caller which ignores its return value, so there's no point in
returning a value.  This incidentally fixes a couple cases where we return a
non const pointer to a string literal.

built and regtested on x86_64-linux-gnu, ok?

Trev

gas/ChangeLog:

2016-02-16  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

	* listing.c (rebuffer_line): Change return type to void.
---
 gas/listing.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/gas/listing.c b/gas/listing.c
index eeb349a..ad597cb 100644
--- a/gas/listing.c
+++ b/gas/listing.c
@@ -553,7 +553,7 @@ buffer_line (file_info_type *file, char *line, unsigned int size)
    back to its original location.  Returns the buffer pointer upon success
    or an empty string if an error occurs.  */
 
-static char *
+static void
 rebuffer_line (file_info_type *  file,
 	       unsigned int      linenum,
 	       char *            buffer,
@@ -569,7 +569,7 @@ rebuffer_line (file_info_type *  file,
 
   /* Sanity checks.  */
   if (file == NULL || buffer == NULL || size <= 1 || file->linenum <= linenum)
-    return "";
+    return;
 
   /* Check the cache and see if we last used this file.  */
   if (last_open_file_info == NULL || file != last_open_file_info)
@@ -587,7 +587,7 @@ rebuffer_line (file_info_type *  file,
       if (last_open_file == NULL)
 	{
 	  file->at_end = 1;
-	  return "";
+	  return;
 	}
 
       /* Seek to where we were last time this file was open.  */
@@ -598,7 +598,7 @@ rebuffer_line (file_info_type *  file,
   /* Remember where we are in the current file.  */
   pos2 = pos = ftell (last_open_file);
   if (pos < 3)
-    return "";
+    return;
   current_line = file->linenum;
 
   /* Leave room for the nul at the end of the buffer.  */
@@ -623,7 +623,7 @@ rebuffer_line (file_info_type *  file,
       if (fread (buffer, 1, size, last_open_file) != size)
 	{
 	  as_warn (_("unable to rebuffer file: %s\n"), file->filename);
-	  return "";
+	  return;
 	}
 
       for (ptr = buffer + size; ptr >= buffer; -- ptr)
@@ -690,8 +690,6 @@ rebuffer_line (file_info_type *  file,
 
   /* Reset the file position.  */
   fseek (last_open_file, pos, SEEK_SET);
-
-  return buffer;
 }
 
 static const char *fn;
-- 
2.7.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]