Skip to content

Comments

Fix compiler warnings, part 5 (rst/interpfl lib & v.surf.rst)#1271

Merged
nilason merged 1 commit intoOSGeo:masterfrom
nilason:fix-compiler-warnings-5
Aug 19, 2021
Merged

Fix compiler warnings, part 5 (rst/interpfl lib & v.surf.rst)#1271
nilason merged 1 commit intoOSGeo:masterfrom
nilason:fix-compiler-warnings-5

Conversation

@nilason
Copy link
Contributor

@nilason nilason commented Jan 25, 2021

Output deviation argument to IL_init_params_2d() and in the interp_params struct (lib/rst/interp_float), was defined as FILE*. In practice a char* of the file path was given to the function in 'v.surf.rst/main.c' and this pointer's only use was to check whether it was NULL or not. It was used as a flag (and this is the reason it worked at all). This changes the argument to be an integer, representing a boolean value a bool.

Addresses one -Wincompatible-pointer-types compiler warning.

/usr/bin/clang  -g -pipe -arch x86_64 -DGL_SILENCE_DEPRECATION    -I/Volumes/grass/dist.x86_64-apple-darwin19.6.0/include -I/Volumes/grass/dist.x86_64-apple-darwin19.6.0/include   -I/opt/local/include -I/opt/local/include  -DPACKAGE=\""grassmods"\"  -I/opt/local/include/postgresql12  -I/Volumes/grass/dist.x86_64-apple-darwin19.6.0/include -I/Volumes/grass/dist.x86_64-apple-darwin19.6.0/include -DRELDIR=\"vector/v.surf.rst\" -o OBJ.x86_64-apple-darwin19.6.0/main.o -c main.c
main.c:646:31: warning: incompatible pointer types passing 'char *' to parameter of type 'FILE *' (aka 'struct __sFILE *') [-Wincompatible-pointer-types]
                      Tmp_fd_yy, Tmp_fd_xy, devi, NULL, cv,
                                            ^~~~
gcc  -std=gnu11   -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include   -I/usr/include/gdal -I/usr/include -fopenmp -DPACKAGE=\""grassmods"\"    -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -DRELDIR=\"vector/v.surf.rst\" -o OBJ.x86_64-pc-linux-gnu/main.o -c main.c
main.c: In function ‘main’:
main.c:646:31: warning: passing argument 41 of ‘IL_init_params_2d’ from incompatible pointer type [-Wincompatible-pointer-types]
  646 |         Tmp_fd_yy, Tmp_fd_xy, devi, NULL, cv,
      |                               ^~~~
      |                               |
      |                               char *
In file included from main.c:40:
/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include/grass/interpf.h:121:58: note: expected ‘FILE *’ {aka ‘struct _IO_FILE *’} but argument is of type ‘char *’
  121 |          FILE *, FILE *, FILE *, FILE *, FILE *, FILE *, FILE *,
      |                                                          ^~~~~~

This is a suggestion of how to address this warning (and wrongful code). I'm aware it breaks API.
I'm looking forward, as always, for input, comments...

Fifth part addressing #1247.

@nilason nilason mentioned this pull request Jan 25, 2021
27 tasks
@nilason nilason force-pushed the fix-compiler-warnings-5 branch from 20c12ef to f0f8aff Compare May 31, 2021 19:57
@nilason nilason marked this pull request as ready for review May 31, 2021 20:02
@nilason nilason requested a review from metzm May 31, 2021 20:15
@nilason
Copy link
Contributor Author

nilason commented May 31, 2021

Updated this PR to use the standard bool type (now included in gis.h).

@nilason nilason added this to the 8.0.0 milestone May 31, 2021
Output deviation argument to IL_init_params_2d() and in the
interp_params struct, was defined as FILE*. In practice a char* of the
file path was given to the function in 'v.surf.rst/main.c' and this
pointer's only use was to check whether it was NULL or not. It was used
as a flag. This changes the argument to be a bool.

Addresses a -Wincompatible-pointer-types compiler warning.
@nilason
Copy link
Contributor Author

nilason commented Aug 17, 2021

Any thoughts on this PR? Would be good to merge/address this for G8.

Copy link
Contributor

@metzm metzm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case breaking the API seems ok to me because it only affects the rst lib and only two modules.

@nilason nilason merged commit 5e2fd30 into OSGeo:master Aug 19, 2021
@nilason nilason deleted the fix-compiler-warnings-5 branch August 24, 2021 19:44
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Oct 26, 2022
Output deviation argument to IL_init_params_2d() and in the
interp_params struct, was defined as FILE*. In practice a char* of the
file path was given to the function in 'v.surf.rst/main.c' and this
pointer's only use was to check whether it was NULL or not. It was used
as a flag. This changes the argument to be a bool.

Addresses a -Wincompatible-pointer-types compiler warning.
petrasovaa added a commit to petrasovaa/grass that referenced this pull request Nov 10, 2022
petrasovaa added a commit that referenced this pull request Nov 11, 2022
petrasovaa added a commit that referenced this pull request Nov 11, 2022
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
Output deviation argument to IL_init_params_2d() and in the
interp_params struct, was defined as FILE*. In practice a char* of the
file path was given to the function in 'v.surf.rst/main.c' and this
pointer's only use was to check whether it was NULL or not. It was used
as a flag. This changes the argument to be a bool.

Addresses a -Wincompatible-pointer-types compiler warning.
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
marisn pushed a commit to marisn/grass that referenced this pull request Jun 2, 2023
neteler pushed a commit to nilason/grass that referenced this pull request Nov 7, 2023
neteler pushed a commit that referenced this pull request Jan 26, 2025
Output deviation argument to IL_init_params_2d() and in the
interp_params struct, was defined as FILE*. In practice a char* of the
file path was given to the function in 'v.surf.rst/main.c' and this
pointer's only use was to check whether it was NULL or not. It was used
as a flag. This changes the argument to be a bool.

Addresses a -Wincompatible-pointer-types compiler warning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants