more -Wall warning fixes from Cristian Ionescu-Idbohrn.

This time it resulted in small code changes:

function                                             old     new   delta
nexpr                                                820     828      +8
tail_main                                           1200    1202      +2
wrapf                                                166     167      +1
parse_mount_options                                  227     209     -18
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 11/-18)             Total: -7 bytes
This commit is contained in:
Denis Vlasenko
2008-05-13 02:27:31 +00:00
parent c4f12f59cc
commit 77ad97f199
27 changed files with 69 additions and 61 deletions

View File

@ -48,5 +48,5 @@ int basename_main(int argc, char **argv)
/* puts(s) will do, but we can do without stdio this way: */
s[m++] = '\n';
return full_write(STDOUT_FILENO, s, m) == m;
return full_write(STDOUT_FILENO, s, m) == (ssize_t)m;
}

View File

@ -64,7 +64,7 @@ static void cut_file(FILE *file, char delim)
/* print the chars specified in each cut list */
for (; cl_pos < nlists; cl_pos++) {
spos = cut_lists[cl_pos].startpos;
while (spos < strlen(line)) {
while (spos < (int)strlen(line)) {
if (!printed[spos]) {
printed[spos] = 'X';
putchar(line[spos]);
@ -80,12 +80,12 @@ static void cut_file(FILE *file, char delim)
/* get out if we have no more lists to process or if the lines
* are lower than what we're interested in */
if (linenum < spos || cl_pos >= nlists)
if (((int)linenum < spos) || (cl_pos >= nlists))
goto next_line;
/* if the line we're looking for is lower than the one we were
* passed, it means we displayed it already, so move on */
while (spos < linenum) {
while (spos < (int)linenum) {
spos++;
/* go to the next list if we're at the end of this one */
if (spos > cut_lists[cl_pos].endpos
@ -97,7 +97,7 @@ static void cut_file(FILE *file, char delim)
spos = cut_lists[cl_pos].startpos;
/* get out if the current line is lower than the one
* we just became interested in */
if (linenum < spos)
if ((int)linenum < spos)
goto next_line;
}
}

View File

@ -65,7 +65,7 @@ static bool write_and_stats(const void *buf, size_t len, size_t obs,
ssize_t n = full_write_or_warn(buf, len, filename);
if (n < 0)
return 1;
if (n == obs)
if ((size_t)n == obs)
G.out_full++;
else if (n) /* > 0 */
G.out_part++;
@ -312,7 +312,7 @@ int dd_main(int argc ATTRIBUTE_UNUSED, char **argv)
while (n) {
size_t d = obs - oc;
if (d > n)
if (d > (size_t)n)
d = n;
memcpy(obuf + oc, tmp, d);
n -= d;

View File

@ -41,7 +41,7 @@ static void expand(FILE *file, unsigned tab_size, unsigned opt)
char *line;
char *ptr;
int convert;
int pos;
unsigned pos;
/* Increment tab_size by 1 locally.*/
tab_size++;
@ -80,7 +80,7 @@ static void unexpand(FILE *file, unsigned int tab_size, unsigned opt)
int convert;
int pos;
int i = 0;
int column = 0;
unsigned column = 0;
while ((line = xmalloc_fgets(file)) != NULL) {
convert = 1;

View File

@ -59,7 +59,8 @@ static struct sort_key {
static char *get_key(char *str, struct sort_key *key, int flags)
{
int start = 0, end = 0, len, i, j;
int start = 0, end = 0, len, j;
unsigned i;
/* Special case whole string, so we don't have to make a copy */
if (key->range[0] == 1 && !key->range[1] && !key->range[2] && !key->range[3]

View File

@ -710,7 +710,7 @@ static void wrapf(const char *message, ...)
{
char buf[128];
va_list args;
int buflen;
unsigned buflen;
va_start(args, message);
buflen = vsnprintf(buf, sizeof(buf), message, args);

View File

@ -92,7 +92,8 @@ int tail_main(int argc, char **argv)
size_t tailbufsize;
int taillen = 0;
int newlines_seen = 0;
int nfiles, nread, nwrite, seen, i, opt;
int nfiles, nread, nwrite, i, opt;
unsigned seen;
int *fds;
char *s, *buf;
@ -210,7 +211,7 @@ int tail_main(int argc, char **argv)
} else if (count) {
if (COUNT_BYTES) {
taillen += nread;
if (taillen > count) {
if (taillen > (int)count) {
memmove(tailbuf, tailbuf + taillen - count, count);
taillen = count;
}
@ -225,7 +226,7 @@ int tail_main(int argc, char **argv)
}
} while (k);
if (newlines_seen + newlines_in_buf < count) {
if (newlines_seen + newlines_in_buf < (int)count) {
newlines_seen += newlines_in_buf;
taillen += nread;
} else {
@ -243,7 +244,7 @@ int tail_main(int argc, char **argv)
memmove(tailbuf, s, taillen);
newlines_seen = count - extra;
}
if (tailbufsize < taillen + BUFSIZ) {
if (tailbufsize < (size_t)taillen + BUFSIZ) {
tailbufsize = taillen + BUFSIZ;
tailbuf = xrealloc(tailbuf, tailbufsize);
}

View File

@ -412,7 +412,7 @@ static int test_eaccess(char *path, int mode)
static int filstat(char *nm, enum token mode)
{
struct stat s;
int i = i; /* gcc 3.x thinks it can be used uninitialized */
unsigned i = i; /* gcc 3.x thinks it can be used uninitialized */
if (mode == FILSYM) {
#ifdef S_IFLNK

View File

@ -219,7 +219,7 @@ int tr_main(int argc ATTRIBUTE_UNUSED, char **argv)
for (;;) {
/* If we're out of input, flush output and read more input. */
if (in_index == read_chars) {
if ((ssize_t)in_index == read_chars) {
if (out_index) {
xwrite(STDOUT_FILENO, (char *)output, out_index);
out_index = 0;