Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #148917

Re: Warning in LLVM Clang

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: Warning in LLVM Clang
Date 2020-01-10 23:52 +0000
Organization A noiseless patient Spider
Message-ID <87v9pihns8.fsf@bsb.me.uk> (permalink)
References (8 earlier) <qv7cp3$47h$1@dont-email.me> <slrnr1f03b.9in.grahn+nntp@frailea.sa.invalid> <qv9g37$kti$1@dont-email.me> <87sgkniiz8.fsf@bsb.me.uk> <qv9vf1$e79$1@dont-email.me>

Show all headers | View raw


Mehdi Amini <atorrses@gmail.com> writes:

> On 1/10/20 4:09 PM, Ben Bacarisse wrote:
>> David Brown <david.brown@hesbynett.no> writes:
>> <cut>
>>> I'd say "fix the code", rather than living with the warnings.
>>
>> In this case, I'm not sure that's the right approach.  If I recall
>> correctly the code is old and stable (some X-Windows program or other)
>> so leaving it well alone might be the safest option.
>>
>> <cut>
>>
>
> Code is a chess GUI which is open-source here available:
>
> https://www.gnu.org/prep/ftp.html
>
> Select a mirror from the list , choose "xboard" package. For now latest
> version is 4.9.1 .
>
> I remember compiling/installing it was not easy job though.
>
> Now some typical warnings from original code:
>
> Code1:
> if(gameNr < 0 || appData.tourneyType < 1 ||  // gauntlet engine can always stay loaded as first engine
>
> Warns1:
>   CC       backend.o
> backend.c: In function ‘ReserveGame’:
> backend.c:1538:7: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
>        if(gameNr < 0 || appData.tourneyType < 1 ||  // gauntlet engine can always stay loaded as first engine
>        ^~

This warning is about code the looks like this:

  if (C)
    S1;
    S2;

The warning is asking you to check if it should be

  if (C) {
    S1;
    S2;
  }

or

  if (C)
    S1;
  S2;

> Code2:
>   { "x", ArgInt, (void *) &wpMain.x, TRUE, (ArgIniType) CW_USEDEFAULT },
> Warns2:
> ./args.h:791:44: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
>    { "x", ArgInt, (void *) &wpMain.x, TRUE, (ArgIniType) CW_USEDEFAULT },
>                                             ^

This one is less interesting.  CW_USEDEFAULT is (probably) a constant of
type int and ArgIniType is (probably) a 64-bit pointer type.  You can
fix this one by including stdint.h and writing

  { "x", ArgInt, (void *) &wpMain.x, TRUE, (ArgIniType)(intptr_t)CW_USEDEFAULT },

> Can I fix such warnings ?

Sure, but is it worth it?  Some might be bugs so you would be helping
out and your patches to the source would be welcome, but others might be
considered as adding noise to the code so you'd be doing it for your own
satisfaction.

-- 
Ben.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-06 17:57 +0330
  Warning in LLVM Clang chad <cdalten@gmail.com> - 2020-01-06 07:47 -0800
  Re: Warning in LLVM Clang Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-06 15:58 +0000
    Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-07 15:32 +0330
      Which compiler is it, anyway??? (Was: Warning in LLVM Clang) gazelle@shell.xmission.com (Kenny McCormack) - 2020-01-07 12:58 +0000
      Re: Warning in LLVM Clang Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-07 14:33 +0000
        Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-08 16:35 +0330
          Re: Warning in LLVM Clang David Brown <david.brown@hesbynett.no> - 2020-01-08 15:11 +0100
            Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-09 16:15 +0330
              Re: Warning in LLVM Clang David Brown <david.brown@hesbynett.no> - 2020-01-09 14:34 +0100
                Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-09 17:49 +0330
                Re: Warning in LLVM Clang Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-09 19:35 +0000
                Re: Warning in LLVM Clang David Brown <david.brown@hesbynett.no> - 2020-01-10 10:28 +0100
                Re: Warning in LLVM Clang Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-10 12:39 +0000
                Re: Warning in LLVM Clang Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-10 12:57 +0000
                Re: Warning in LLVM Clang Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-10 13:23 +0000
                Re: Warning in LLVM Clang David Brown <david.brown@hesbynett.no> - 2020-01-10 14:09 +0100
                Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-10 16:45 +0330
                Re: Warning in LLVM Clang Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-10 13:20 +0000
                Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-10 17:20 +0330
                Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-10 17:24 +0330
                Re: Warning in LLVM Clang Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-10 23:52 +0000
                Re: Warning in LLVM Clang scott@slp53.sl.home (Scott Lurndal) - 2020-01-10 15:29 +0000
                Re: Warning in LLVM Clang Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-10 23:28 +0000
                Re: Warning in LLVM Clang Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-11 14:21 +0000
              Re: Warning in LLVM Clang James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-09 22:08 -0500
                Not exactly an "alias", but that's just being a CLC pedant... (Was: Warning in LLVM Clang) gazelle@shell.xmission.com (Kenny McCormack) - 2020-01-10 09:52 +0000
                Re: Not exactly an "alias", but that's just being a CLC pedant... (Was: Warning in LLVM Clang) David Brown <david.brown@hesbynett.no> - 2020-01-10 11:26 +0100
                Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-10 16:48 +0330
                Re: Warning in LLVM Clang Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-10 09:34 -0800
                Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-11 14:41 +0330
  Re: Warning in LLVM Clang Guillaume <message@bottle.org> - 2020-01-06 17:23 +0100
    Re: Warning in LLVM Clang Mehdi Amini <atorrses@gmail.com> - 2020-01-07 15:39 +0330

csiph-web