Skip to content

Comments

Fix compiler warnings, part 8#1276

Closed
nilason wants to merge 5 commits intoOSGeo:masterfrom
nilason:fix-compiler-warnings-8
Closed

Fix compiler warnings, part 8#1276
nilason wants to merge 5 commits intoOSGeo:masterfrom
nilason:fix-compiler-warnings-8

Conversation

@nilason
Copy link
Contributor

@nilason nilason commented Jan 27, 2021

Fixes compiler warnings:

  • -Wincompatible-pointer-types-discards-qualifiers
  • -Wunused-result
  • -Wheader-guard
  • "too many arguments in call to function"

Eighth part addressing #1247.

Note: there are a few cases of OGR error handling added, please do pay special attention to them and their implementation.

Modules / code parts directly affected:

  • lib/raster
  • lib/imagery
  • lib/nviz
  • lib/vector/Vlib
  • db/drivers/ogr
  • general/g.parser
  • raster/r.fill.stats
  • raster3d/r3.retile
  • raster/r.horizon
  • raster/r.random
  • vector/v.lrs/v.lrs.create
  • vector/v.lrs/v.lrs.label
  • vector/v.lrs/v.lrs.segment
  • vector/v.lrs/v.lrs.where
  • vector/v.rectify

@nilason nilason mentioned this pull request Jan 27, 2021
27 tasks
@nilason nilason force-pushed the fix-compiler-warnings-8 branch from 355284f to fb249f2 Compare February 5, 2021 10:53
@nilason nilason marked this pull request as ready for review February 5, 2021 11:14
nilason and others added 5 commits February 7, 2021 16:09
Fixes -Wheader-guard compiler warnings.
Fixes -Wunused-result compiler warnings.

Co-authored-by: Markus Metz <[email protected]>
Fixes -Wincompatible-pointer-types-discards-qualifiers
compiler warnings.
Addresses -Wincompatible-pointer-types-discards-qualifiers
compiler warnings.
@nilason nilason force-pushed the fix-compiler-warnings-8 branch from fb249f2 to 6a84665 Compare February 7, 2021 15:18
@nilason
Copy link
Contributor Author

nilason commented Feb 7, 2021

Updated commit messages and I believe it is ready for merge.

I did split the original "-Wincompatible-pointer-types-discards-qualifiers" fix commit into two, depending on the cause of the warning (and nature of fix).

A note regarding the cast of the result of db_get_default_driver_name(). The function is defined as:

const char *db_get_default_driver_name(void)

but in fact returns a char *:

return G_store(drv);

which is here then re-casted back to char *.

@metzm
Copy link
Contributor

metzm commented Feb 7, 2021

A note regarding the cast of the result of db_get_default_driver_name(). The function is defined as:

const char *db_get_default_driver_name(void)

but in fact returns a char *:

return G_store(drv);

which is here then re-casted back to char *.

IMHO, db_get_default_driver_name() is correct, it provides the default driver name which should not be modified, thus const. Within the scope of this PR, I think re-casting back to char * is fine.

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.

Ready to merge, thanks a lot!

@nilason
Copy link
Contributor Author

nilason commented Feb 8, 2021

IMHO, db_get_default_driver_name() is correct, it provides the default driver name which should not be modified, thus const. Within the scope of this PR, I think re-casting back to char * is fine.

Oh, I do understand the logic that db_get_default_driver_name() is a const and agree it's correct. Only brought it up because I suggested the return value could be wrapped in a G_store() instead of casting, but that wouldn't make much sense in light of its implementation.

nilason added a commit that referenced this pull request Feb 8, 2021
Fixes -Wheader-guard compiler warnings.
nilason added a commit that referenced this pull request Feb 8, 2021
Fixes -Wunused-result compiler warnings.

Co-authored-by: Markus Metz <[email protected]>
nilason added a commit that referenced this pull request Feb 8, 2021
nilason added a commit that referenced this pull request Feb 8, 2021
Fixes -Wincompatible-pointer-types-discards-qualifiers
compiler warnings.
nilason added a commit that referenced this pull request Feb 8, 2021
Addresses -Wincompatible-pointer-types-discards-qualifiers
compiler warnings.
@nilason
Copy link
Contributor Author

nilason commented Feb 8, 2021

Cherry picked and pushed to master.
Thank you!

@nilason nilason closed this Feb 8, 2021
@nilason
Copy link
Contributor Author

nilason commented Feb 8, 2021

@metzm
Regarding the structure member Option->answer and the casting problems it seem to cause. I noticed that originally (at least with G5) all (string) members were char *, but this changed in 2008 (G6.4) to what we see today. Only answer (and answers) stayed mutable. The question is: do you think it's worth the effort to even explore the possibility to change ´answer´ to a const? Or will that set me off in a one-way road?

@nilason nilason deleted the fix-compiler-warnings-8 branch February 14, 2021 13:05
marisn pushed a commit to marisn/grass that referenced this pull request Mar 22, 2021
Fixes -Wheader-guard compiler warnings.
marisn pushed a commit to marisn/grass that referenced this pull request Mar 22, 2021
Fixes -Wunused-result compiler warnings.

Co-authored-by: Markus Metz <[email protected]>
marisn pushed a commit to marisn/grass that referenced this pull request Mar 22, 2021
marisn pushed a commit to marisn/grass that referenced this pull request Mar 22, 2021
Fixes -Wincompatible-pointer-types-discards-qualifiers
compiler warnings.
marisn pushed a commit to marisn/grass that referenced this pull request Mar 22, 2021
Addresses -Wincompatible-pointer-types-discards-qualifiers
compiler warnings.
@neteler neteler added this to the 8.0.0 milestone Dec 9, 2021
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Oct 26, 2022
Fixes -Wheader-guard compiler warnings.
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Oct 26, 2022
Fixes -Wunused-result compiler warnings.

Co-authored-by: Markus Metz <[email protected]>
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Oct 26, 2022
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Oct 26, 2022
Fixes -Wincompatible-pointer-types-discards-qualifiers
compiler warnings.
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Oct 26, 2022
Addresses -Wincompatible-pointer-types-discards-qualifiers
compiler warnings.
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
Fixes -Wheader-guard compiler warnings.
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
Fixes -Wunused-result compiler warnings.

Co-authored-by: Markus Metz <[email protected]>
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
Fixes -Wincompatible-pointer-types-discards-qualifiers
compiler warnings.
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
Addresses -Wincompatible-pointer-types-discards-qualifiers
compiler warnings.
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.

3 participants