This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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, MIPS] Returning array literal from find_translit2


Here is another warning/error I get from locale/programs/ld-ctype.c when
building glibc on MIPS:


programs/ld-ctype.c: In function 'find_translit':
cc1: error: function may return address of local variable [-Werror=return-local-addr]
programs/ld-ctype.c:1780:29: note: declared here
        return (uint32_t []) { 0 };
                             ^
cc1: error: function may return address of local variable [-Werror=return-local-addr]
programs/ld-ctype.c:1780:29: note: declared here
cc1: all warnings being treated as errors



My proposed fix is to create a static global that can be returned instead
of the array literal.  Does this look like the right way to fix this?
Is there a better name than zero to use?

I tested it with no regressions, OK to checkin?


2014-12-11  Steve Ellcey  <sellcey@imgtec.com>

	* locale/programs/ld-ctype.c (zero): New static global variable.
	(find_translit2): Return zero instead of array literal.


diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c
index 67846b3..01de017 100644
--- a/locale/programs/ld-ctype.c
+++ b/locale/programs/ld-ctype.c
@@ -1724,6 +1724,7 @@ to-value character sequence is smaller than from-value sequence"));
     }
 }
 
+static uint32_t zero[] = { 0 };
 
 static uint32_t *
 find_translit2 (struct locale_ctype_t *ctype, const struct charmap_t *charmap,
@@ -1777,7 +1778,7 @@ find_translit2 (struct locale_ctype_t *ctype, const struct charmap_t *charmap,
 
 	  for (wi = tirunp->from; wi <= wch; wi += tirunp->step)
 	    if (wi == wch)
-	      return (uint32_t []) { 0 };
+	      return zero;
 	}
     }
 


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