On Tue, May 06, 2014 at 10:57:57PM +0200, Fritjof Bornebusch wrote:
> Hi tech,
> 
> if I compile rcs, gcc prints a few warnings like this:
> - comparison between signed and unsigned
> - signed and unsigned type in conditional expression
> 
> I'm not quite sure if the typecasts are at the correct place, but these diffs 
> removes the warnings.
> 
> fritjof
> 
> 
> Index: buf.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/rcs/buf.c,v
> retrieving revision 1.22
> diff -u -p -r1.22 buf.c
> --- buf.c       6 Jul 2011 15:36:52 -0000       1.22
> +++ buf.c       6 May 2014 20:56:55 -0000
> @@ -98,7 +98,7 @@ buf_load(const char *path)
>         if (fstat(fd, &st) == -1)
>                 goto out;
>  
> -       if (st.st_size > SIZE_MAX) {
> +       if (st.st_size > (off_t)SIZE_MAX) {
>                 errno = EFBIG;
>                 goto out;
>         }
> 
> Index: diff.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/rcs/diff.c,v
> retrieving revision 1.34
> diff -u -p -r1.34 diff.c
> --- diff.c      16 May 2013 12:44:48 -0000      1.34
> +++ diff.c      6 May 2014 20:57:07 -0000
> @@ -432,13 +432,13 @@ prepare(int i, FILE *fd, off_t filesize,
>  
>         rewind(fd);
>  
> -       sz = (filesize <= SIZE_MAX ? filesize : SIZE_MAX) / 25;
> +       sz = (filesize <= (off_t)SIZE_MAX ? filesize : (off_t)SIZE_MAX) / 25;
>         if (sz < 100)
>                 sz = 100;
>  
>         p = xcalloc(sz + 3, sizeof(*p));
>         for (j = 0; (h = readhash(fd, flags));) {
> -               if (j == sz) {
> +               if ((size_t)j == sz) {
>                         sz = sz * 3 / 2;
>                         p = xrealloc(p, sz + 3, sizeof(*p));
>                 }
> 
> Index: diff3.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/rcs/diff3.c,v
> retrieving revision 1.33
> diff -u -p -r1.33 diff3.c
> --- diff3.c     4 Mar 2012 04:05:15 -0000       1.33
> +++ diff3.c     6 May 2014 20:57:18 -0000
> @@ -908,7 +908,7 @@ edscript(int n)
>                 (void)fseek(fp[2], (long)de[n].new.from, SEEK_SET);
>                 for (k = de[n].new.to-de[n].new.from; k > 0; k-= j) {
>                         j = k > BUFSIZ ? BUFSIZ : k;
> -                       if (fread(block, 1, j, fp[2]) != j)
> +                       if ((int)fread(block, 1, j, fp[2]) != j)
>                                 return (-1);
>                         block[j] = '\0';
>                         diff_output("%s", block);
> 
> Index: buf.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/rcs/buf.c,v
> retrieving revision 1.22
> diff -u -p -r1.22 buf.c
> --- buf.c       6 Jul 2011 15:36:52 -0000       1.22
> +++ buf.c       6 May 2014 20:57:30 -0000
> @@ -98,7 +98,7 @@ buf_load(const char *path)
>         if (fstat(fd, &st) == -1)
>                 goto out;
>  
> -       if (st.st_size > SIZE_MAX) {
> +       if (st.st_size > (off_t)SIZE_MAX) {
>                 errno = EFBIG;
>                 goto out;
>         }
> 

Does no one want to check the diff and give me some feedback?

fritjof

Reply via email to