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

Fix new compiler warnings #2118

Merged
merged 3 commits into from
Jun 5, 2024
Merged

Conversation

jan-cerny
Copy link
Member

These compiler warnings appeared with latest GCC on F40 (gcc-14.1.1-4.fc40.x86_64).

This should solve the failing "Build, Test on Fedora Latest" CI job.

For more details, please read commit messages of each commit.

jan-cerny added 3 commits June 3, 2024 14:29
Addressing:

In file included from /home/jcerny/work/git/openscap/src/common/elements.c:43:
/home/jcerny/work/git/openscap/src/common/elements.c: In function ‘oscap_xml_save_filename’:
/home/jcerny/work/git/openscap/src/common/elements.c:237:41: warning: passing argument 4 of ‘__oscap_setxmlerr’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  237 |                         oscap_setxmlerr(xmlGetLastError());
      |                                         ^~~~~~~~~~~~~~~~~
/home/jcerny/work/git/openscap/src/common/_error.h:36:92: note: in definition of macro ‘oscap_setxmlerr’
   36 | #define oscap_setxmlerr(error) __oscap_setxmlerr (__FILE__, __LINE__, __PRETTY_FUNCTION__, error)
      |                                                                                            ^~~~~
/home/jcerny/work/git/openscap/src/common/_error.h:38:87: note: expected ‘xmlErrorPtr’ {aka ‘struct _xmlError *’} but argument is of type ‘const xmlError *’ {aka ‘const struct _xmlError *’}
   38 | void __oscap_setxmlerr(const char *file, uint32_t line, const char *func, xmlErrorPtr error);
      |                                                                           ~~~~~~~~~~~~^~~~~
Addressing:

In function ‘ipv6addr_mask’,
    inlined from ‘ipaddr_mask’ at /home/jcerny/work/git/openscap/src/OVAL/results/oval_cmp_ip_address.c:79:3,
    inlined from ‘ipaddr_mask’ at /home/jcerny/work/git/openscap/src/OVAL/results/oval_cmp_ip_address.c:74:20,
    inlined from ‘oval_ipaddr_cmp’ at /home/jcerny/work/git/openscap/src/OVAL/results/oval_cmp_ip_address.c:171:3:
/home/jcerny/work/git/openscap/src/OVAL/results/oval_cmp_ip_address.c:280:34: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
  280 |                 addr->s6_addr[i] &= mask;
      |                 ~~~~~~~~~~~~~~~~~^~~~~~~
/home/jcerny/work/git/openscap/src/OVAL/results/oval_cmp_ip_address.c: In function ‘oval_ipaddr_cmp’:
/home/jcerny/work/git/openscap/src/OVAL/results/oval_cmp_ip_address.c:98:14: note: at offset [-268435456, -1] into destination object ‘addr2’ of size 46
   98 |         char addr2[INET6_ADDRSTRLEN];
      |              ^~~~~
Addressing:

/home/jcerny/work/git/openscap/src/source/bz2.c: In function ‘bz2_mem_open’:
/home/jcerny/work/git/openscap/src/source/bz2.c:127:43: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
  127 |         struct bz2_mem *b = calloc(sizeof(struct bz2_mem), 1);
      |                                           ^~~~~~
/home/jcerny/work/git/openscap/src/source/bz2.c:127:43: note: earlier argument should specify number of elements, later size of each element
/home/jcerny/work/git/openscap/src/source/bz2.c:128:35: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
  128 |         b->stream = calloc(sizeof(bz_stream), 1);
      |                                   ^~~~~~~~~
/home/jcerny/work/git/openscap/src/source/bz2.c:128:35: note: earlier argument should specify number of elements, later size of each element
Copy link
Contributor

@evgenyz evgenyz left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks.

@evgenyz evgenyz merged commit 0c3f815 into OpenSCAP:main Jun 5, 2024
14 of 16 checks passed
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