Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings while building this project #21

Closed
mingodad opened this issue Jul 13, 2021 · 6 comments
Closed

Warnings while building this project #21

mingodad opened this issue Jul 13, 2021 · 6 comments
Labels

Comments

@mingodad
Copy link
Contributor

Hello when compiling this project on ubuntu 18.04 I'm getting this warnings:

make[1]: Entering directory '/home/mingo/dev/c/A_grammars/unicc'
depbase=`echo src/parse.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
/usr/bin/gcc -DPACKAGE_NAME=\"UniCC\" -DPACKAGE_TARNAME=\"unicc\" -DPACKAGE_VERSION=\"1.7.0\" -DPACKAGE_STRING=\"UniCC\ 1.7.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"unicc\" -DVERSION=\"1.7.0\" -DHAVE_LIBRT=1 -DUNICODE=1 -DUTF8=1 -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_MEMSET=1 -DHAVE_STRRCHR=1 -I.  -DTLTDIR=\"/usr/share/unicc/targets\"   -g3 -gdwarf-2 -MT src/parse.o -MD -MP -MF $depbase.Tpo -c -o src/parse.o src/parse.c &&\
mv -f $depbase.Tpo $depbase.Po
src/parse.par: In function ‘parse_error’:
src/parse.par:338:16: warning: pointer type mismatch in conditional expression
  338 |         parser->p_prefix, strbuf, FALSE ); *]
      |                ^
...
depbase=`echo src/debug.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
/usr/bin/gcc -DPACKAGE_NAME=\"UniCC\" -DPACKAGE_TARNAME=\"unicc\" -DPACKAGE_VERSION=\"1.7.0\" -DPACKAGE_STRING=\"UniCC\ 1.7.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"unicc\" -DVERSION=\"1.7.0\" -DHAVE_LIBRT=1 -DUNICODE=1 -DUTF8=1 -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_MEMSET=1 -DHAVE_STRRCHR=1 -I.  -DTLTDIR=\"/usr/share/unicc/targets\"   -g3 -gdwarf-2 -MT src/debug.o -MD -MP -MF $depbase.Tpo -c -o src/debug.o src/debug.c &&\
mv -f $depbase.Tpo $depbase.Po
src/debug.c: In function ‘dump_grammar’:
src/debug.c:61:19: warning: too many arguments for format [-Wformat-extra-args]
   61 |  fprintf( stream, "\nGRAMMAR\n\n",
      |                   ^~~~~~~~~~~~~~~
...
@mingodad
Copy link
Contributor Author

It seems that the #line generation is not working properly because after commenting all //#line in parser.c and compiling again we get:

make[1]: Entering directory '/home/mingo/dev/c/A_grammars/unicc'
depbase=`echo src/parse.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
/usr/bin/gcc -DPACKAGE_NAME=\"UniCC\" -DPACKAGE_TARNAME=\"unicc\" -DPACKAGE_VERSION=\"1.7.0\" -DPACKAGE_STRING=\"UniCC\ 1.7.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"unicc\" -DVERSION=\"1.7.0\" -DHAVE_LIBRT=1 -DUNICODE=1 -DUTF8=1 -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_MEMSET=1 -DHAVE_STRRCHR=1 -I.  -DTLTDIR=\"/usr/share/unicc/targets\"   -g3 -gdwarf-2 -MT src/parse.o -MD -MP -MF $depbase.Tpo -c -o src/parse.o src/parse.c &&\
mv -f $depbase.Tpo $depbase.Po
src/parse.c: In function ‘parse_error’:
src/parse.c:5596:16: warning: pointer type mismatch in conditional expression
 5596 |       pcb->buf :  _symbols[ pcb->sym ].name,
      |                ^
	print_error( parser, expect ? ERR_PARSE_ERROR_EXPECT : ERR_PARSE_ERROR,
				ERRSTYLE_FATAL | ERRSTYLE_FILEINFO,
					parser->filename, pcb->line,
					pcb->sym == -1 ?
						pcb->buf :  _symbols[ pcb->sym ].name,   ///!!! here is the warning
					expect ? expect : "(unknown)" );

@mingodad
Copy link
Contributor Author

Adding the -Wall -Wextra compiler flags gives us several other interesting warnings like:

lib/phorward.c: In function ‘pccl_compare’:
lib/phorward.c:1523:14: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
 1523 |   return ret < 0 ? -1 : 1;
      |              ^
...
src/xml.c: In function ‘xml_internal_dtd’:
src/xml.c:571:18: warning: operation on ‘s’ may be undefined [-Wsequence-point]
  571 |    while( *( n = ++s + strspn(s, XML_WS) ) && *n != '>' )
      |                  ^~~

@phorward
Copy link
Owner

phorward commented Dec 4, 2021

Hello @mingodad, thank you for filing this issue. Can you please provide a pull request for solving all warnings you already found?

@phorward phorward added the bug label Dec 4, 2021
phorward added a commit that referenced this issue Jul 21, 2022
See #21 for details.
@phorward
Copy link
Owner

Hello @mingodad, #30 removes most of the reported warnings.

The only one I don't know how to solve is this one, as s seems not the be uninitialized.

src/xml.c: In function ‘xml_internal_dtd’:
src/xml.c:571:18: warning: operation on ‘s’ may be undefined [-Wsequence-point]
  571 |    while( *( n = ++s + strspn(s, XML_WS) ) && *n != '>' )
      |                  ^~~

@mingodad
Copy link
Contributor Author

This is not elegant but it's aligned with the actual code style and seems to solve the problem:

while( *( ++s, n = s + strspn(s, XML_WS) ) && *n != '>' )

phorward added a commit that referenced this issue Jul 22, 2022
@phorward
Copy link
Owner

This is not elegant but it's aligned with the actual code style and seems to solve the problem:

while( *( ++s, n = s + strspn(s, XML_WS) ) && *n != '>' )

Perfect, that works. I've integrated this in #30 commit 6d3d5d5. Thank you!

phorward added a commit that referenced this issue Jul 22, 2022
* Removing several warnings

See #21 for details.

* Added warning fix by @mingodad

Proposal from comment #21 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants