lynx-dev
[Top][All Lists]
Advanced

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

Re: [Lynx-dev] Fixing some warnings.


From: Juan Manuel Guerrero
Subject: Re: [Lynx-dev] Fixing some warnings.
Date: Tue, 06 Jun 2017 13:06:26 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.13) Gecko/20101206 SUSE/3.1.7 Thunderbird/3.1.7

Am 06.06.2017 02:15, schrieb Thomas Dickey:
On Mon, Jun 05, 2017 at 10:45:36PM +0200, Juan Manuel Guerrero wrote:
While I was checking the DJGPP code I have submitted, I have found certain
warnings/issues that I have tried to fix.  See patch below; it is only a
suggestion.

thanks (will review/etc)



OFYI, after having applied my DJGPP patch to the sources I have compiled the
code on a linux machine using gcc 6.1.0 with the options -Wall -pedantic.  I
was surprised about the warnings I got.  E.g.:

gcc -DHAVE_CONFIG_H  -DLOCALEDIR=\"/usr/local/share/locale\" -I. -I.. 
-Ichrtrans -I../../lynx2.8.9dev.14/src/chrtrans -I../../lynx2.8.9dev.14 
-I../../lynx2.8.9dev.14/src -I../../lynx2.8.9dev.14/./WWW/Library/Implementation    
-D_GNU_SOURCE -D_DEFAULT_SOURCE -DLINUX -O2  -c ../../lynx2.8.9dev.14/src/HTML.c
../../lynx2.8.9dev.14/src/HTML.c: In function ‘HTML_start_element’:
../../lynx2.8.9dev.14/src/HTML.c:3714:28: warning: comparison between pointer 
and zero character constant [-Wpointer-compare]
       if (me->object_title == '\0') {
                            ^~
../../lynx2.8.9dev.14/src/HTML.c:3714:11: note: did you mean to dereference the 
pointer?
       if (me->object_title == '\0') {
           ^

The code itself confuses me a little bit.  Either the intention is to check
against NULL pointer, then the original code is wrong.  IMHO it should look
like this:
  if (me->object_title == NULL) {


Or the intention is to check that the strings are empty before deallocating
them, then the code should look like this:
  if (me->object_title[0] == '\0') {


The reason why I have submitted the patch as it is, is because after having
inspected function HTML_start_element, I have found the following line:
  if (*me->object_usemap == '\0') {

that produces no compiler warnings, thus I have assumed that this was the
intention of the other lines.  I have adjusted them accordingly.  But to
be serious, I do not understand the goal of those lines at all.  If the goal
is to deallocate the strings, I do not understand why it is necessary to check
that they are not NULL pointers and why it is necessary to check that they are
empty.  Why is not called the free function directly with the pointer.
But again the patch is only the result of my observations when compiling
the code.  If the patch does make any sense can only be judge by the authors
of lynx.

Kind regards,
Juan M. Guerrero



reply via email to

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