Skip to content

Fix null pointer warning for string argument to parse_struct in registry code#196

Merged
mgduda merged 1 commit intoMPAS-Dev:developfrom
mgduda:framework/fix_parse_struct_null_string
Apr 9, 2019
Merged

Fix null pointer warning for string argument to parse_struct in registry code#196
mgduda merged 1 commit intoMPAS-Dev:developfrom
mgduda:framework/fix_parse_struct_null_string

Conversation

@mgduda
Copy link
Copy Markdown
Contributor

@mgduda mgduda commented Apr 4, 2019

This merge fixes a null pointer warning for a string argument to parse_struct
in the registry code.

The fifth argument to the parse_struct function in the gen_inc code is
a const char*. The call to parse_struct previously passed a C null character,
'\0', which evaluates to zero and is therefore interpreted as a null pointer.
It was likely intended to pass an empty C string, i.e., a string consisting
of a single null character, in the call to parse_struct, using "\0" rather
than '\0'. This was picked up by the XL C compiler:

gen_inc.c:2531:52: warning: expression which evaluates to zero treated as a null pointer constant of type 'const char *'
[-Wnon-literal-null-conversion]
                err = parse_struct(fd, registry, structs_xml, 0, '\0', corename);
                                                                 ^~~~

This warning turns out to be harmless, as the fifth argument to parse_struct
is only used when the fourth argument is non-zero.

…try code

The fifth argument to the parse_struct function in the gen_inc code is
a const char*. The call to parse_struct previously passed a C null character,
'\0', which evaluates to zero and is therefore interpreted as a null pointer.
It was likely intended to pass an empty C string, i.e., a string consisting
of a single null character, in the call to parse_struct, using "\0" rather
than '\0'. This was picked up by the XL C compiler:

gen_inc.c:2531:52: warning: expression which evaluates to zero treated as a null pointer constant of type 'const char *'
[-Wnon-literal-null-conversion]
                err = parse_struct(fd, registry, structs_xml, 0, '\0', corename);
                                                                 ^~~~
This warning turns out to be harmless, as the fifth argument to parse_struct
is only used when the fourth argument is non-zero.
@mgduda
Copy link
Copy Markdown
Contributor Author

mgduda commented Apr 4, 2019

I think it should be reasonable to test PRs #196 #197 #198 and #199 together.

Copy link
Copy Markdown
Contributor

@mark-petersen mark-petersen left a comment

Choose a reason for hiding this comment

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

Visual check, passes ocean nightly regression suite.

@mgduda mgduda merged commit c1d1556 into MPAS-Dev:develop Apr 9, 2019
mgduda added a commit that referenced this pull request Apr 9, 2019
…#196)

This merge fixes a null pointer warning for a string argument to parse_struct
in the registry code.

The fifth argument to the parse_struct function in the gen_inc code is
a const char*. The call to parse_struct previously passed a C null character,
'\0', which evaluates to zero and is therefore interpreted as a null pointer.
It was likely intended to pass an empty C string, i.e., a string consisting
of a single null character, in the call to parse_struct, using "\0" rather
than '\0'. This was picked up by the XL C compiler:

gen_inc.c:2531:52: warning: expression which evaluates to zero treated as a null pointer constant of type 'const char *'
[-Wnon-literal-null-conversion]
                err = parse_struct(fd, registry, structs_xml, 0, '\0', corename);
                                                                 ^~~~

This warning turns out to be harmless, as the fifth argument to parse_struct
is only used when the fourth argument is non-zero.

* framework/fix_parse_struct_null_string:
  Fix null pointer warning for string argument to parse_struct in registry code
@mgduda mgduda deleted the framework/fix_parse_struct_null_string branch April 9, 2019 19:56
mark-petersen added a commit that referenced this pull request Apr 10, 2019
Updating MPAS framework. This includes:
- Rename Makefile.in.ACME to Makefile.in.E3SM: #195
- Change Makefile.in.E3SM to standard CESM formatting (TRUE in caps): #191
- Add -Uvector to Makefile.in.E3SM to ignore the word 'vector' in comments when using GEN_F90=TRUE: #200, fixes #2725
- Fix memory leak due to double allocate, only used by RK4 time stepping, does not change E3SM runs: #185
- Changes to atmosphere directories are not used by E3SM.
- COMPASS testing updates, not used by E3SM, including python 3 updates.
- Fix typos that cause warnings on some compilers: #196, #197, #198, #199
mark-petersen added a commit that referenced this pull request Apr 10, 2019
Updating MPAS framework. This includes:
- Rename Makefile.in.ACME to Makefile.in.E3SM: #195
- Change Makefile.in.E3SM to standard CESM formatting (TRUE in caps): #191
- Add -Uvector to Makefile.in.E3SM to ignore the word 'vector' in comments when using GEN_F90=TRUE: #200, fixes #2725
- Fix memory leak due to double allocate, only used by RK4 time stepping, does not change E3SM runs: #185
- Changes to atmosphere directories are not used by E3SM.
- COMPASS testing updates, not used by E3SM, including python 3 updates.
- Fix typos that cause warnings on some compilers: #196, #197, #198, #199
ashwathsv pushed a commit to ashwathsv/MPAS-Model that referenced this pull request Jul 21, 2020
Updating MPAS framework. This includes:
- Rename Makefile.in.ACME to Makefile.in.E3SM: MPAS-Dev#195
- Change Makefile.in.E3SM to standard CESM formatting (TRUE in caps): MPAS-Dev#191
- Add -Uvector to Makefile.in.E3SM to ignore the word 'vector' in comments when using GEN_F90=TRUE: MPAS-Dev#200, fixes #2725
- Fix memory leak due to double allocate, only used by RK4 time stepping, does not change E3SM runs: MPAS-Dev#185
- Changes to atmosphere directories are not used by E3SM.
- COMPASS testing updates, not used by E3SM, including python 3 updates.
- Fix typos that cause warnings on some compilers: MPAS-Dev#196, MPAS-Dev#197, MPAS-Dev#198, MPAS-Dev#199
mark-petersen added a commit to mark-petersen/MPAS-Model that referenced this pull request Jan 11, 2021
Updating MPAS framework. This includes:
- Rename Makefile.in.ACME to Makefile.in.E3SM: MPAS-Dev#195
- Change Makefile.in.E3SM to standard CESM formatting (TRUE in caps): MPAS-Dev#191
- Add -Uvector to Makefile.in.E3SM to ignore the word 'vector' in comments when using GEN_F90=TRUE: MPAS-Dev#200, fixes #2725
- Fix memory leak due to double allocate, only used by RK4 time stepping, does not change E3SM runs: MPAS-Dev#185
- Changes to atmosphere directories are not used by E3SM.
- COMPASS testing updates, not used by E3SM, including python 3 updates.
- Fix typos that cause warnings on some compilers: MPAS-Dev#196, MPAS-Dev#197, MPAS-Dev#198, MPAS-Dev#199
caozd999 pushed a commit to caozd999/MPAS-Model that referenced this pull request Jan 14, 2021
Updating MPAS framework. This includes:
- Rename Makefile.in.ACME to Makefile.in.E3SM: MPAS-Dev#195
- Change Makefile.in.E3SM to standard CESM formatting (TRUE in caps): MPAS-Dev#191
- Add -Uvector to Makefile.in.E3SM to ignore the word 'vector' in comments when using GEN_F90=TRUE: MPAS-Dev#200, fixes #2725
- Fix memory leak due to double allocate, only used by RK4 time stepping, does not change E3SM runs: MPAS-Dev#185
- Changes to atmosphere directories are not used by E3SM.
- COMPASS testing updates, not used by E3SM, including python 3 updates.
- Fix typos that cause warnings on some compilers: MPAS-Dev#196, MPAS-Dev#197, MPAS-Dev#198, MPAS-Dev#199
mark-petersen added a commit to mark-petersen/MPAS-Model that referenced this pull request Jan 16, 2021
Updating MPAS framework. This includes:
- Rename Makefile.in.ACME to Makefile.in.E3SM: MPAS-Dev#195
- Change Makefile.in.E3SM to standard CESM formatting (TRUE in caps): MPAS-Dev#191
- Add -Uvector to Makefile.in.E3SM to ignore the word 'vector' in comments when using GEN_F90=TRUE: MPAS-Dev#200, fixes #2725
- Fix memory leak due to double allocate, only used by RK4 time stepping, does not change E3SM runs: MPAS-Dev#185
- Changes to atmosphere directories are not used by E3SM.
- COMPASS testing updates, not used by E3SM, including python 3 updates.
- Fix typos that cause warnings on some compilers: MPAS-Dev#196, MPAS-Dev#197, MPAS-Dev#198, MPAS-Dev#199
mark-petersen added a commit to mark-petersen/MPAS-Model that referenced this pull request Jan 19, 2021
Updating MPAS framework. This includes:
- Rename Makefile.in.ACME to Makefile.in.E3SM: MPAS-Dev#195
- Change Makefile.in.E3SM to standard CESM formatting (TRUE in caps): MPAS-Dev#191
- Add -Uvector to Makefile.in.E3SM to ignore the word 'vector' in comments when using GEN_F90=TRUE: MPAS-Dev#200, fixes #2725
- Fix memory leak due to double allocate, only used by RK4 time stepping, does not change E3SM runs: MPAS-Dev#185
- Changes to atmosphere directories are not used by E3SM.
- COMPASS testing updates, not used by E3SM, including python 3 updates.
- Fix typos that cause warnings on some compilers: MPAS-Dev#196, MPAS-Dev#197, MPAS-Dev#198, MPAS-Dev#199
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants