#54 Small code nits

Closed
opened 1 year ago by devnexen · 8 comments
devnexen commented 1 year ago
Collaborator

Few compiler warning I get with current code on master :

engine/vm.c / line 941, the last argument might deserve an explicit cast.
include/ph7int.h / line 1892 ; engine/lib/libzip.c / line 514, just stylistic here no newline at end of file.

Few compiler warning I get with current code on master : `engine/vm.c / line 941`, the last argument might deserve an explicit cast. `include/ph7int.h / line 1892` ; `engine/lib/libzip.c / line 514`, just stylistic here `no newline at end of file`.
belliash self-assigned this 1 year ago
belliash commented 1 year ago
Owner

Do they come from GCC or any other compiler? Could you post the entire build log?

Do they come from GCC or any other compiler? Could you post the entire build log?
devnexen commented 1 year ago
Poster
Collaborator

gcc 8 in my part :
engine/vm.c: In function ‘PH7_VmInit’: engine/vm.c:941:56: warning: passing argument 4 of ‘SyHashInit’ from incompatible pointer type [-Wincompatible-pointer-types] SyHashInit(&pVm->hClass, &pVm->sAllocator, SyStrHash, SyStrncmp); signature of the callback not really matching, seems "picky" here IMHO but a cast would not kill.

gcc 8 in my part : `engine/vm.c: In function ‘PH7_VmInit’: engine/vm.c:941:56: warning: passing argument 4 of ‘SyHashInit’ from incompatible pointer type [-Wincompatible-pointer-types] SyHashInit(&pVm->hClass, &pVm->sAllocator, SyStrHash, SyStrncmp);` signature of the callback not really matching, seems "picky" here IMHO but a cast would not kill.
belliash commented 1 year ago
Owner

This is not as simple to correct. The callback function is used in several places and its signature does not match only here.

This is not as simple to correct. The callback function is used in several places and its signature does not match only here.
devnexen commented 1 year ago
Poster
Collaborator

I meant the cast only on this line but as said that s cosmetic, it works as it anyway.

I meant the cast only on this line but as said that s cosmetic, it works as it anyway.
devnexen was assigned by belliash 1 year ago
belliash commented 1 year ago
Owner

I think, we can cast this just to remove this ugly warning. Anyway you will need to commit a fix, as I have a faulty PC and currently cannot work on AerScript. Im waiting for hardware I ordered.

I think, we can cast this just to remove this ugly warning. Anyway you will need to commit a fix, as I have a faulty PC and currently cannot work on AerScript. Im waiting for hardware I ordered.
likoski commented 1 year ago
Owner

There is one more global warning:

gcc -std=c99 -D_GNU_SOURCE -fPIC -Iinclude -I. -Wunused -Wall -Wextra -Wpedantic -DPH7_LIBRARY_SUFFIX=".so" -O3 -s -c engine/api.c -o build/engine/api.o
engine/api.c: In function ‘ProcessSourceFile’:
engine/api.c:637:49: warning: ‘__builtin_snprintf’ output may be truncated before the last format character [-Wformat-truncation=]
637 | snprintf(pFilePath, sizeof(pFilePath) - 1, "%s", fFilePath);
| ^
In file included from /usr/include/stdio.h:867,
from include/ph7.h:52,
from include/ph7int.h:18,
from engine/api.c:10:
/usr/include/bits/stdio2.h:67:10: note: ‘__builtin_snprintf’ output between 1 and 4097 bytes into a destination of size 4096
67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68 | __bos (__s), __fmt, __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Additionally, when compiling with release optimization, there is one more:

gcc -std=c99 -D_GNU_SOURCE -fPIC -Iinclude -I. -Wunused -Wall -Wextra -Wpedantic -DPH7_LIBRARY_SUFFIX=".so" -O3 -s -c engine/parser.c -o build/engine/parser.o
engine/parser.c: In function ‘PH7_ExprMakeTree’:
engine/parser.c:241:10: warning: array subscript 1760 is outside array bounds of ‘const ph7_expr_op[55]’ {aka ‘const struct ph7_expr_op[55]’} [-Warray-bounds]
241 | pEnd = &pOp[sizeof(aOpTable)];
| ^~~~~~~~~~~~~~~~~~~
engine/parser.c:26:26: note: while referencing ‘aOpTable’
26 | static const ph7_expr_op aOpTable[] = {
| ^~~~~~~~
engine/parser.c:241:10: warning: array subscript 1760 is outside array bounds of ‘const ph7_expr_op[55]’ {aka ‘const struct ph7_expr_op[55]’} [-Warray-bounds]
241 | pEnd = &pOp[sizeof(aOpTable)];
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
engine/parser.c:26:26: note: while referencing ‘aOpTable’
26 | static const ph7_expr_op aOpTable[] = {
| ^~~~~~~~

There is one more global warning: gcc -std=c99 -D_GNU_SOURCE -fPIC -Iinclude -I. -Wunused -Wall -Wextra -Wpedantic -DPH7_LIBRARY_SUFFIX=\".so\" -O3 -s -c engine/api.c -o build/engine/api.o engine/api.c: In function ‘ProcessSourceFile’: engine/api.c:637:49: warning: ‘__builtin_snprintf’ output may be truncated before the last format character [-Wformat-truncation=] 637 | snprintf(pFilePath, sizeof(pFilePath) - 1, "%s", fFilePath); | ^ In file included from /usr/include/stdio.h:867, from include/ph7.h:52, from include/ph7int.h:18, from engine/api.c:10: /usr/include/bits/stdio2.h:67:10: note: ‘__builtin_snprintf’ output between 1 and 4097 bytes into a destination of size 4096 67 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | __bos (__s), __fmt, __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Additionally, when compiling with release optimization, there is one more: gcc -std=c99 -D_GNU_SOURCE -fPIC -Iinclude -I. -Wunused -Wall -Wextra -Wpedantic -DPH7_LIBRARY_SUFFIX=\".so\" -O3 -s -c engine/parser.c -o build/engine/parser.o engine/parser.c: In function ‘PH7_ExprMakeTree’: engine/parser.c:241:10: warning: array subscript 1760 is outside array bounds of ‘const ph7_expr_op[55]’ {aka ‘const struct ph7_expr_op[55]’} [-Warray-bounds] 241 | pEnd = &pOp[sizeof(aOpTable)]; | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ engine/parser.c:26:26: note: while referencing ‘aOpTable’ 26 | static const ph7_expr_op aOpTable[] = { | ^~~~~~~~ engine/parser.c:241:10: warning: array subscript 1760 is outside array bounds of ‘const ph7_expr_op[55]’ {aka ‘const struct ph7_expr_op[55]’} [-Warray-bounds] 241 | pEnd = &pOp[sizeof(aOpTable)]; | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ engine/parser.c:26:26: note: while referencing ‘aOpTable’ 26 | static const ph7_expr_op aOpTable[] = { | ^~~~~~~~
likoski commented 1 year ago
Owner

I believe 33b0f20573 fixes on of them.

I believe 33b0f20573 fixes on of them.
belliash was unassigned by likoski 1 year ago
likoski self-assigned this 1 year ago
devnexen was unassigned by likoski 1 year ago
likoski commented 1 year ago
Owner

Fixed second problem with 843c2d67d9.

Fixed second problem with 843c2d67d9.
likoski closed this issue 1 year ago
Sign in to join this conversation.
No Milestone
No Assignees
3 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.