tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] tiny bit of lint


From: Christian Jullien
Subject: Re: [Tinycc-devel] tiny bit of lint
Date: Mon, 8 May 2017 08:09:01 +0200

Just to give you an example, trying splint only on x86_64-gen.c, I get >
2000 of warnings!!

Something like:

tcc.h: (in function is_space)
tcc.h:1244:12: Operands of == have incompatible types (int, char): ch == ' '
  A character constant is used as an int. Use +charintliteral to allow
  character constants to be used as ints.  (This is safe since the actual
type
  of a char constant is int.)
tcc.h:1244:25: Operands of == have incompatible types (int, char): ch ==
'\t'
arm64-gen.c:49:31: Initializer block for reg_classes has 28 elements, but
    declared as int [25]: 0x0001 | RC_R(0), 0x0001 | RC_R(1), 0x0001 |
RC_R(2),
    0x0001 | RC_R(3), 0x0001 | RC_R(4), 0x0001 | RC_R(5), 0x0001 | RC_R(6),
    0x0001 | RC_R(7), 0x0001 | RC_R(8), 0x0001 | RC_R(9), 0x0001 | RC_R(10),
    0x0001 | RC_R(11), 0x0001 | RC_R(12), 0x0001 | RC_R(13), 0x0001 |
RC_R(14),
    0x0001 | RC_R(15), 0x0001 | RC_R(16), 0x0001 | RC_R(17), 0x0001 |
RC_R(18),
    RC_R30, 0x0002 | RC_F(0), 0x0002 | RC_F(1), 0x0002 | RC_F(2), 0x0002 |
    RC_F(3), 0x0002 | RC_F(4), 0x0002 | RC_F(5), 0x0002 | RC_F(6), 0x0002 |
    RC_F(7)
  Initializer block contains more elements than the size of a declared
array.
arm64-gen.c:300:30: Left operand of << may be negative (int): bas << 5

-----Original Message-----
From: Tinycc-devel [mailto:address@hidden
On Behalf Of Christian Jullien
Sent: lundi 8 mai 2017 07:48
To: address@hidden
Subject: Re: [Tinycc-devel] tiny bit of lint

Hi Larry,

I share this hobby with you but only with my own projects.
If you like to chase warnings in C, I invite you to forget those 'chicken'
checks and to move to something stronger such as (from easier to stronger):

* clang and --analyze
* VC++ -analyse
* smatch that helped to find ~3000 Linux kernel bugs
* splint which is my favorite and much more parano that you can imagine in
your dreams (or nightmares) => http://www.splint.org/

splint helped me to find real bugs hard to catch. Using splint is a sport.
It makes you feel you are a C noob.

I never use splint on projects that I don't own .. unless I'm ready to stop
using them :o))

-----Original Message-----
From: Tinycc-devel [mailto:address@hidden
On Behalf Of Larry Doolittle
Sent: lundi 8 mai 2017 05:13
To: address@hidden
Subject: [Tinycc-devel] tiny bit of lint

Esteemed tinycc maintainers -

One of my hobbies is turning up the C compiler warning level in projects I'm
interested in, and seeing what lint shows up.  Tinycc is really pretty
clean.

Using gcc's -Wextra, I found 17 "unused parameter", which could be addressed
by bloating the source code a bit (casting to void), and with no consequence
on the binary.  If anyone else thought that would be an improvement, I'd be
happy to write and submit a patch.

Using gcc's -Wextra, I found 23 "missing initializer for field", all
generated by macros in x86_64-asm.h.  I would not be able to test any
attempt to improve that situation, so I'll leave it alone.

Using gcc's -Wwrite-strings, I found one simple lack-of-const in tcctools.c,
patch attached.  The patch has zero effect on the code's functionality.
That patch also adds "undef strict-prototypes write-strings" to the list of
warning flags that will be used if present.

I'm a fan of using the writer/editor paradigm, so I won't actually commit
this to mob myself.  I encourage someone in-tune with community values to
put on their editor's hat, double-check that my patch makes sense and
doesn't break anything, and then commit it or suggest changes.

   - Larry


_______________________________________________
Tinycc-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/tinycc-devel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]