From patchwork Thu Dec 11 17:57:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 4188 Received: (qmail 28501 invoked by alias); 11 Dec 2014 17:57:33 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 28487 invoked by uid 89); 11 Dec 2014 17:57:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mailapp01.imgtec.com From: "Steve Ellcey " Date: Thu, 11 Dec 2014 09:57:19 -0800 To: Subject: [Patch, MIPS] Returning array literal from find_translit2 User-Agent: Heirloom mailx 12.5 6/20/10 MIME-Version: 1.0 Message-ID: <4cd4f5d8-d93b-47ff-b039-9fbef4d9ee37@BAMAIL02.ba.imgtec.org> 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 * 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; } }