Fix compiler warnings generated with gcc(version 5.4.0) flags = "-g -O2 -Wall -Werror -fPIC -D_LARGEFILE_SOURCE -Wno-unused-result"

Description

gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609

The following warnings are being treated as errors.

1)

pbs_upgrade_job.c: In function ‘upgrade_job_file’:
pbs_upgrade_job.c:316:13: error: logical not is only applied to the left hand side of comparison [-Werror=logical-not-parentheses]
if (!tmpfd < 0) {
^
pbs_upgrade_job.c: In function ‘upgrade_task_file’:
pbs_upgrade_job.c:458:13: error: logical not is only applied to the left hand side of comparison [-Werror=logical-not-parentheses]
if (!tmpfd < 0) {
^
cc1: all warnings being treated as errors

2)

In file included from /usr/include/string.h:635:0,
from pbs_log.c:68:
In function ‘strncat’,
inlined from ‘log_add_debug_info’ at pbs_log.c:389:3:
/usr/include/x86_64-linux-gnu/bits/string3.h:156:10: error: call to builtin_strncat_chk might overflow destination buffer [-Werror]
return _builtin_strncat_chk (dest, __src, __len, __bos (_dest));
^
In function ‘strncat’,
inlined from ‘log_add_debug_info’ at pbs_log.c:394:2:
/usr/include/x86_64-linux-gnu/bits/string3.h:156:10: error: call to builtin_strncat_chk might overflow destination buffer [-Werror]
return _builtin_strncat_chk (dest, __src, __len, __bos (_dest));
^
In function ‘strncat’,
inlined from ‘log_add_debug_info’ at pbs_log.c:400:3:
/usr/include/x86_64-linux-gnu/bits/string3.h:156:10: error: call to builtin_strncat_chk might overflow destination buffer [-Werror]
return _builtin_strncat_chk (dest, __src, __len, __bos (_dest));
^
In function ‘strncat’,
inlined from ‘log_add_debug_info’ at pbs_log.c:403:2:
/usr/include/x86_64-linux-gnu/bits/string3.h:156:10: error: call to builtin_strncat_chk might overflow destination buffer [-Werror]
return _builtin_strncat_chk (dest, __src, __len, __bos (_dest));
^
In function ‘strncat’,
inlined from ‘log_add_if_info’ at pbs_log.c:446:4:
/usr/include/x86_64-linux-gnu/bits/string3.h:156:10: error: call to builtin_strncat_chk might overflow destination buffer [-Werror]
return _builtin_strncat_chk (dest, __src, __len, __bos (_dest));

3)

In function ‘snprintf’,
inlined from ‘im_request’ at mom_comm.c:2847:7:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: error: call to builtin_snprintf_chk will always overflow destination buffer [-Werror]
return _builtin_snprintf_chk (_s, __n, __USE_FORTIFY_LEVEL - 1,
^
cc1: all warnings being treated as errors

4)

In file included from /usr/include/stdio.h:936:0,
from /usr/include/python2.7/Python.h:33,
from mom_main.c:47:
In function ‘snprintf’,
inlined from ‘initialize’ at mom_main.c:1212:6:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: error: call to builtin_snprintf_chk will always overflow destination buffer [-Werror]
return _builtin_snprintf_chk (_s, __n, __USE_FORTIFY_LEVEL - 1,
^
cc1: all warnings being treated as errors

Acceptance Criteria

Fix all warnings in source.

Activity

Show:
Michael Karo
April 23, 2018, 2:37 PM

It would be helpful to document the warnings/errors produced. Could you please post them here ?

Sanidhya
April 24, 2018, 5:54 AM
Edited

I was of the understanding that only "-Wall -Werror" were responsible for this but apart from #1 all other errors do not appear so I have added all flags that were initially used. Using them produces the above errors.

Sanidhya
May 4, 2018, 7:56 AM

Made changes to (error) warnings and compilation is now successful with set flags.

Assignee

Sanidhya

Reporter

Sanidhya

Severity

1-Low

OS

None

Start Date

None

Pull Request URL

Story Points

1

Fix versions

Affects versions

Priority

Low
Configure