mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: build with clang-3.4 warnings report
Date: Sat, 5 Apr 2014 11:31:15 +0200	[thread overview]
Message-ID: <20140405093115.GK3034@port70.net> (raw)
In-Reply-To: <1396688698.11744.258.camel@eris.loria.fr>

* Jens Gustedt <jens.gustedt@inria.fr> [2014-04-05 11:04:58 +0200]:
> This seems to come from the bogus handling of EDQUOT by mips:
> 
> 	/* mips has one error code outside of the 8-bit range due to a
> 	 * historical typo, so we just remap it. */
> 
> This remapping seems only to have been done correctly for the strerror
> function itself but not for the array declaration.
> 
> An equivalent patch for that line would be
> 
> #define E(a,b) (unsigned char)((EDQUOT==1133 && (a)==EDQUOT) ? 109 : a),
> 
> but which makes it only apparent how bogus this is.

the cast should be fine

1133%256 == 109

and 109 is an unused errno number on mips

(this is why the mips bug can be worked around and yes it's ugly
but at least it does not penalize other archs)

> To "repair" the mips problem I would just do
> 
> I think the real bug is here
> 
> #define E(a,b) ((unsigned char)a),
> 
> this is a typical case of someone using a cast to burry a
> problem, black magic, "casting a spell".

you forgot to write what would you do :)

the cast hides a compiler warning about the >UCHAR_MAX errno

(making the warning visible makes sense, however i highly doubt
there ever will be another broken errno)

> As this bug shows, the whole technique of searching the error string
> in strerror is somehow fragile.
> 
> The whole thing could be avoided by using designated initializers and
> eliminating the whole errid array right away. Designated initializers
> should be present in all decent versions of gcc. Do you want me to
> prepare a patch?

how?

strerror is size optimized

(there are various ways to do strerror, but i could not improve
on rich's code)


  reply	other threads:[~2014-04-05  9:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-04 19:59 Abdoulaye Walsimou Gaye
2014-04-04 20:47 ` Rich Felker
2014-04-05  1:06   ` Abdoulaye Walsimou Gaye
2014-04-05  1:54     ` Rich Felker
2014-04-05  9:04       ` Jens Gustedt
2014-04-05  9:31         ` Szabolcs Nagy [this message]
2014-04-05 13:07         ` Rich Felker
2014-04-05 14:37           ` Jens Gustedt
2014-04-05 16:35             ` Rich Felker
2014-04-05 22:08               ` Jens Gustedt
2014-04-06  1:57                 ` Rich Felker
2014-04-06 16:37                   ` Jens Gustedt
2014-04-06 16:49                     ` Rich Felker
2014-04-07 11:17       ` Oliver Schneider
2014-04-07 17:23         ` Rich Felker
2014-04-07 19:40           ` Abdoulaye Walsimou Gaye

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140405093115.GK3034@port70.net \
    --to=nsz@port70.net \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).