mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
build: avoid false -Wmaybe-uninitialized warnings
Allow easily building a debug build for example with:
make CFLAGS='-O0 -ggdb'
False -Wmaybe-uninitialized warnings hit in different
places depending on the compiler passes used.
These changes were tested with gcc 10.2.1, 12.2.1, and 13.1.1 like:
for o in g s z fast 0 1 2 3; do
make clean && make -j$(nproc) CFLAGS="-O$o" || break
done
* src/digest.c: Disable -Wmaybe-uninitialized that gives
false positive here at -O0.
* src/ln.c: Avoid -Wmaybe-uninitialized that gives
false positive here at -O1.
* src/pr.c: Likewise.
* src/sort.c: Likewise.
* src/tee.c: Avoid -Wmaybe-uninitialized that gives
false positive here at -O3 on gcc 13.1.1 at least.
* src/cp.c: Avoid -Wmaybe-uninitialized that gives
false positive here at -Os on gcc 13.1.1 at least.
* src/copy.c: Avoid -Wmaybe-uninitialized that gives
false positive here at -Og on gcc 13.1.1 at least.
* src/head.c: Likewise.
* src/paste.c: Likewise.
This commit is contained in:
1 parent
aed3b8190a
commit
800c86d5fa
9 files changed
+12
-9
No files matched your search
+2
-2
@@ -1238,8 +1238,8 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
struct stat const *src_sb)
|
||||
{
|
||||
char *buf = NULL;
|
||||
int dest_desc;
|
||||
int dest_errno;
|
||||
int dest_desc IF_LINT ( = -1);
|
||||
int dest_errno IF_LINT ( = 0);
|
||||
int source_desc;
|
||||
mode_t src_mode = src_sb->st_mode;
|
||||
mode_t extra_permissions;
|
||||
|
||||
@@ -441,7 +441,7 @@ make_dir_parents_private (char const *const_dir, size_t src_offset,
|
||||
|
||||
while ((slash = strchr (slash, '/')))
|
||||
{
|
||||
struct dir_attr *new;
|
||||
struct dir_attr *new IF_LINT ( = NULL);
|
||||
bool missing_dir;
|
||||
|
||||
*slash = '\0';
|
||||
|
||||
@@ -1125,6 +1125,9 @@ hex_equal (unsigned char const *hex_digest, unsigned char const *bin_buffer)
|
||||
return cnt == digest_bin_bytes;
|
||||
}
|
||||
|
||||
#if defined __GNUC__ && (__GNUC__ + (__GNUC_MINOR__ >= 7) > 4)
|
||||
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
#endif
|
||||
static bool
|
||||
digest_check (char const *checkfile_name)
|
||||
{
|
||||
|
||||
+1
-1
@@ -351,7 +351,7 @@ elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0,
|
||||
bytes. Then, for each new buffer we read, also write an old one. */
|
||||
|
||||
bool eof = false;
|
||||
size_t n_read;
|
||||
size_t n_read IF_LINT ( = 0);
|
||||
bool buffered_enough;
|
||||
size_t i, i_next;
|
||||
char **b = NULL;
|
||||
|
||||
@@ -473,7 +473,7 @@ main (int argc, char **argv)
|
||||
char const *backup_suffix = NULL;
|
||||
char *version_control_string = NULL;
|
||||
char const *target_directory = NULL;
|
||||
int destdir_fd;
|
||||
int destdir_fd IF_LINT ( = -1);
|
||||
bool no_target_directory = false;
|
||||
int n_files;
|
||||
char **file;
|
||||
|
||||
+1
-1
@@ -233,7 +233,7 @@ paste_parallel (size_t nfiles, char **fnamptr)
|
||||
|
||||
for (size_t i = 0; i < nfiles && files_open; i++)
|
||||
{
|
||||
int chr; /* Input character. */
|
||||
int chr IF_LINT ( = -1); /* Input character. */
|
||||
int err; /* Input errno value. */
|
||||
bool sometodo = false; /* Input chars to process. */
|
||||
|
||||
|
||||
@@ -2428,7 +2428,7 @@ static bool
|
||||
read_line (COLUMN *p)
|
||||
{
|
||||
int c;
|
||||
int chars;
|
||||
int chars IF_LINT ( =0);
|
||||
int last_input_position;
|
||||
int j, k;
|
||||
COLUMN *q;
|
||||
|
||||
+1
-1
@@ -1045,7 +1045,7 @@ pipe_fork (int pipefds[2], size_t tries)
|
||||
struct tempnode *saved_temphead;
|
||||
int saved_errno;
|
||||
double wait_retry = 0.25;
|
||||
pid_t pid;
|
||||
pid_t pid IF_LINT ( = -1);
|
||||
struct cs_status cs;
|
||||
|
||||
if (pipe2 (pipefds, O_CLOEXEC) < 0)
|
||||
|
||||
Reference in new issue
Block a user