summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-04-22 01:07:01 +0100
committerPádraig Brady <P@draigBrady.com>2015-04-22 11:11:19 +0100
commit8878c4ef1b88fd07a48ccd7df6bff7ba0929dad7 (patch)
treef427316aa66d271bfc031d1701629d5e2a69a212
parent01f4065b129c6ad55eef765e701d0e20342867c7 (diff)
downloadcoreutils-8878c4ef1b88fd07a48ccd7df6bff7ba0929dad7.tar.xz
maint: avoid -Werror=strict-overflow warnings with GCC 5
All warnings were of the form: "assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]" * src/dd.c (cache_round): Use an appropriately sized unsigned type, to avoid possibility of undefined signed overflow. * src/mknod.c (main): Likewise. * src/pr.c (pad_down): Likewise. * src/wc.c (main): Likewise. * src/tail.c (main): Assert that argc >= 0 thus allowing the compiler to assume without implication that argc - optind is positive.
-rw-r--r--src/dd.c2
-rw-r--r--src/mknod.c2
-rw-r--r--src/pr.c6
-rw-r--r--src/tail.c2
-rw-r--r--src/wc.c10
5 files changed, 12 insertions, 10 deletions
diff --git a/src/dd.c b/src/dd.c
index e78f2a290..321b096d4 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -987,7 +987,7 @@ cache_round (int fd, off_t len)
if (len)
{
- off_t c_pending = *pending + len;
+ uintmax_t c_pending = *pending + len;
*pending = c_pending % page_size;
if (c_pending > *pending)
len = c_pending - *pending;
diff --git a/src/mknod.c b/src/mknod.c
index 2804aaf7c..73342ce29 100644
--- a/src/mknod.c
+++ b/src/mknod.c
@@ -94,7 +94,7 @@ main (int argc, char **argv)
mode_t newmode;
char const *specified_mode = NULL;
int optc;
- int expected_operands;
+ size_t expected_operands;
mode_t node_type;
char const *scontext = NULL;
bool set_security_context = false;
diff --git a/src/pr.c b/src/pr.c
index 78fe69799..6ff51ec5a 100644
--- a/src/pr.c
+++ b/src/pr.c
@@ -438,7 +438,7 @@ static void init_store_cols (void);
static void store_columns (void);
static void balance (int total_stored);
static void store_char (char c);
-static void pad_down (int lines);
+static void pad_down (unsigned int lines);
static void read_rest_of_line (COLUMN *p);
static void skip_read (COLUMN *p, int column_number);
static void print_char (char c);
@@ -2052,9 +2052,9 @@ pad_across_to (int position)
Otherwise, use newlines. */
static void
-pad_down (int lines)
+pad_down (unsigned int lines)
{
- int i;
+ unsigned int i;
if (use_form_feed)
putchar ('\f');
diff --git a/src/tail.c b/src/tail.c
index f75d7a9ee..b29dab1c9 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -2180,6 +2180,8 @@ main (int argc, char **argv)
--n_units;
}
+ IF_LINT (assert (0 <= argc));
+
if (optind < argc)
{
n_files = argc - optind;
diff --git a/src/wc.c b/src/wc.c
index 91f4a3145..fe73d2ce1 100644
--- a/src/wc.c
+++ b/src/wc.c
@@ -558,7 +558,7 @@ wc_file (char const *file, struct fstatus *fstatus)
that happens when we don't know how long the list of file names will be. */
static struct fstatus *
-get_input_fstatus (int nfiles, char *const *file)
+get_input_fstatus (size_t nfiles, char *const *file)
{
struct fstatus *fstatus = xnmalloc (nfiles ? nfiles : 1, sizeof *fstatus);
@@ -570,7 +570,7 @@ get_input_fstatus (int nfiles, char *const *file)
fstatus[0].failed = 1;
else
{
- int i;
+ size_t i;
for (i = 0; i < nfiles; i++)
fstatus[i].failed = (! file[i] || STREQ (file[i], "-")
@@ -586,7 +586,7 @@ get_input_fstatus (int nfiles, char *const *file)
get_input_fstatus optimizes. */
static int _GL_ATTRIBUTE_PURE
-compute_number_width (int nfiles, struct fstatus const *fstatus)
+compute_number_width (size_t nfiles, struct fstatus const *fstatus)
{
int width = 1;
@@ -594,7 +594,7 @@ compute_number_width (int nfiles, struct fstatus const *fstatus)
{
int minimum_width = 1;
uintmax_t regular_total = 0;
- int i;
+ size_t i;
for (i = 0; i < nfiles; i++)
if (! fstatus[i].failed)
@@ -620,7 +620,7 @@ main (int argc, char **argv)
{
bool ok;
int optc;
- int nfiles;
+ size_t nfiles;
char **files;
char *files_from = NULL;
struct fstatus *fstatus;