Re: [dev] [st] [PATCH] Fix techo handling of control and multibyte characters.

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Mon, 28 Apr 2014 17:36:42 +0200

>> The problem is Wall change from one system to another (this is something
>> OpenBSD users know with strcpy calls...), and it doesn't force how to
>> remove the warning, so at the end I think style is not really improved
>> with Wall (and guys, some of the warning are really, really stupid).

> There is no solution to this but to either fix the platforms or the com‐
> piler. St does not have to adapt.

I agree with you, but I think is we want to follow a style, we have to
write a style guide, and not follow the Wall of the compiler, that
can change, and that generate a lot of incorrect warnings. For example,
after my last patch, compiling in linux you do not get any warning,
but if you compile in OpenBSD you get this output:

In file included from /usr/X11R6/include/X11/Xlib.h:47,
                 from st.c:25:
/usr/X11R6/include/X11/Xfuncproto.h:144:24: warning: ISO C does not permit named variadic macros
st.c: In function 'techo':
st.c:2303: warning: comparison is always false due to limited range of data type
st.c:2303: warning: comparison is always true due to limited range of data type
CC -o st
/usr/X11R6/lib/libX11.so.16.0: warning: strcpy() is almost always misused, please use strlcpy()
/usr/X11R6/lib/libX11.so.16.0: warning: strcat() is almost always misused, please use strlcat()
/usr/X11R6/lib/libX11.so.16.0: warning: sprintf() is often misused, please use snprintf()

What I should do here? Fix these warnings that are not shown in linux?, and
if I don't fix them, how do I know that a warning if generated only in
OpenBSD and it is not generated in Linux?, I have to compile in all
the possible systems and fix all the warning that every compiler
give me?. If we want to follow warning as a style guide we should
explititly put what warnings we want to honour and not rely in
Wall.

Another problem related to the style is you only can know what style is
used guessing it from the source, but in the source you can find
some things like:

        if(term.c.x+width < term.col) {
                tmoveto(term.c.x+width, term.c.y);
        } else {
                term.c.state |= CURSOR_WRAPNEXT;
        }

but you also can find:

        if(xwrite(cmdfd, s, n) == -1)
                die("write error on tty: %s\n", strerror(errno));

So, is it mandatory parenthesis in one line if? I don't know it.

Regards,

-- 
Roberto E. Vargas Caballero
Received on Mon Apr 28 2014 - 17:36:42 CEST

This archive was generated by hypermail 2.3.0 : Mon Apr 28 2014 - 17:48:09 CEST