From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11646 Path: news.gmane.org!.POSTED!not-for-mail From: Alexander Monakov Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] remove ineffective compiler assist from printf Date: Tue, 4 Jul 2017 22:53:12 +0300 Message-ID: <20170704195312.24387-1-amonakov@ispras.ru> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1499198012 5073 195.159.176.226 (4 Jul 2017 19:53:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 4 Jul 2017 19:53:32 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-11659-gllmg-musl=m.gmane.org@lists.openwall.com Tue Jul 04 21:53:28 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dSTt1-00011j-49 for gllmg-musl@m.gmane.org; Tue, 04 Jul 2017 21:53:27 +0200 Original-Received: (qmail 28076 invoked by uid 550); 4 Jul 2017 19:53:30 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 28037 invoked from network); 4 Jul 2017 19:53:28 -0000 X-Mailer: git-send-email 2.11.0 Xref: news.gmane.org gmane.linux.lib.musl.general:11646 Archived-At: The switch statement has no 'default:' case and the function ends immediately following the switch, so the extra comparison did not communicate any extra information to the compiler. --- Someone reported this on IRC a few weeks ago. MAXSTATE enum value is unused after this change. Removal reduces code size slightly with gcc-6. Alexander src/stdio/vfprintf.c | 2 -- src/stdio/vfwprintf.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c index 8c81efc2..15356f53 100644 --- a/src/stdio/vfprintf.c +++ b/src/stdio/vfprintf.c @@ -107,8 +107,6 @@ union arg static void pop_arg(union arg *arg, int type, va_list *ap) { - /* Give the compiler a hint for optimizing the switch. */ - if ((unsigned)type > MAXSTATE) return; switch (type) { case PTR: arg->p = va_arg(*ap, void *); break; case INT: arg->i = va_arg(*ap, int); diff --git a/src/stdio/vfwprintf.c b/src/stdio/vfwprintf.c index b8fff208..6e7492a7 100644 --- a/src/stdio/vfwprintf.c +++ b/src/stdio/vfwprintf.c @@ -119,8 +119,6 @@ union arg static void pop_arg(union arg *arg, int type, va_list *ap) { - /* Give the compiler a hint for optimizing the switch. */ - if ((unsigned)type > MAXSTATE) return; switch (type) { case PTR: arg->p = va_arg(*ap, void *); break; case INT: arg->i = va_arg(*ap, int); -- 2.11.0