zsh-workers
 help / color / mirror / code / Atom feed
* IS_DASH() warning
@ 2017-03-10  7:27 ` Bart Schaefer
  2017-03-10  9:46   ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 2017-03-10  7:27 UTC (permalink / raw)
  To: Zsh hackers list

glob.c:2398:10: warning: comparison of constant -101 with expression of type
      'unsigned char' is always false
      [-Wtautological-constant-out-of-range-compare]
            if (IS_DASH(c1) && lastch >= 0 && p < str2 && lastch <= (int)c2) {
                ^~~~~~~~~~~
./zsh.h:248:39: note: expanded from macro 'IS_DASH'
#define IS_DASH(x) ((x) == '-' || (x) == Dash)
                                  ~~~ ^  ~~~~

(It's complaining about the comparison to Dash if proportional font
misplaces the caret.)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: IS_DASH() warning
  2017-03-10  7:27 ` IS_DASH() warning Bart Schaefer
@ 2017-03-10  9:46   ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2017-03-10  9:46 UTC (permalink / raw)
  To: Zsh hackers list

On Thu, 9 Mar 2017 23:27:36 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:

> glob.c:2398:10: warning: comparison of constant -101 with expression of type
>       'unsigned char' is always false
>       [-Wtautological-constant-out-of-range-compare]
>             if (IS_DASH(c1) && lastch >= 0 && p < str2 && lastch <= (int)c2) {
>                 ^~~~~~~~~~~
> ./zsh.h:248:39: note: expanded from macro 'IS_DASH'
> #define IS_DASH(x) ((x) == '-' || (x) == Dash)
>                                   ~~~ ^  ~~~~
> 
> (It's complaining about the comparison to Dash if proportional font
> misplaces the caret.)

I presume I'm not going to see this warning anyway, but Dash is cast to
char so the only obvious thing to do is cast c1, which is currently
unsigned.  Alternatively, IS_DASH could be even more clumsy with casts
to both Dash and the input character to unsigned.

pws

diff --git a/Src/glob.c b/Src/glob.c
index 87127e1..0fcb4e1 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -2395,7 +2395,8 @@ xpandbraces(LinkList list, LinkNode *np)
 		c2 = ztokens[c2 - STOUC(Pound)];
 	    if ((char) c2 == Meta)
 		c2 = 32 ^ p[1];
-	    if (IS_DASH(c1) && lastch >= 0 && p < str2 && lastch <= (int)c2) {
+	    if (IS_DASH((char)c1) && lastch >= 0 &&
+		p < str2 && lastch <= (int)c2) {
 		while (lastch < (int)c2)
 		    ccl[lastch++] = 1;
 		lastch = -1;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-03-10  9:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20170310072841epcas2p2340dcec5f380c88168d615f3df3de89d@epcas2p2.samsung.com>
2017-03-10  7:27 ` IS_DASH() warning Bart Schaefer
2017-03-10  9:46   ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

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

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).