2013.10.28 07:43 "[Tiff] Does TIFF support 15-bit (RGB555 or 5551) images?", by Nikos Chantziaras

2013.12.03 15:18 "Re: [Tiff] Compile problem in tif_jpeg.c", by Bob Friesenhahn

On Mon, 2 Dec 2013, Nacho Man wrote:

> Hey, I haven't used mailing lists in a long time.   Just a quick

question. I reply to this message (like I'm doing now), does   When it just go to you Bob or does everyone on the mailing list receive it? should be everyone, because of the CC to   It

> tiff@lists.maptools.org, right?  Thanks.

This depends on the mailing list setting and how your mail client behaves. If your mail client does not tell you who your mail is addressed to, then you should get a different mail client.

> I do get some warnings when I compile now.   Like in

tiff-4.0.3/contrib/iptcutil/iptcutil.c:241:4:
warning: comparison is always false due to limited range of data type [-Wtype-limits]
And

> some warnings about variables being set but never used.  I created a

simple C program to try and figure out why I'm getting the comparison is always true or false. is the code for that.   Below

#include <stdio.h>
#include <stdlib.h>

int main() {

>     char c;
>
>     FILE *ifile=fopen("mytestfile","r");
>
>     while ((c = getc(ifile)) != EOF) {
>         printf("%c",c);
>     }

}

When I compile it using my native GNU C compiler on my Linux system

> with the -Wtype-limits flag, I get no errors.   If I use the PS3's

Toolchain GCC to compile it, I get the warning: comparison is always

> true due to limited range of data type [-Wtype-limits] warning.   If

I change the char c; to signed char c; and try to compile, no   a error. thought that was weird though. though the value range   I   I

> for a signed char was -127 to 127 and for unsigned 0 - 255.   Seeing

how the ASCII character chart goes from 0-255, wouldn't I need to use unsigned and not signed? character read from the file would   Any

> be between 0-255, right?   There shouldn't be any negative values. 

Could someone explain if those warnings are correct and should I change the codes in the tiff library so it uses signed char's

> instead of just char's for the various warning messages?  Thanks.

If you look at the documentation for getc(), you will find that it returns an integer type so your code is wrong. Your code would not detect EOF since EOF is usually integer -1. ASCII is from 0-127, not to 255.

Regardless of if 'char' defaults to signed or unsigned, these may be captured in a buffer as bytes (a string) without changing values. Functions which deal with a single 'char' usually pass an 'int' type instead.

The iptcutil.c code is not at all wonderful or an example of correct coding practices.

Bob
--
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/