warnings, signed issues, gcc 4.0

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

warnings, signed issues, gcc 4.0

Andreas Jellinghaus-2
Hi,

I found a number of warnings, some related to signing issues.
we have some issue with gcc 4.0 (opensc "doesn't work"), so
I started to look at these.

openct issues:
 - ps_transceive_instruction use "void *" buffers, not "char *"
   (conflicts with "unsigned char*" buffers, all other code
    uses void*).
 - replace LPSTR with LPTSTR. does anyone know if that would
   cause problems on old machines / old pcsc-lite?
 
opensc:
reader-pcsc.c:984: warning: pointer targets in passing argument 3 of
'sc_bin_to_hex' differ in signedness

opensc.h:int sc_bin_to_hex(const u8 *, size_t, char *, size_t, int separator);

target buffer is only used for printing the hex string, so it is safe to
change it from u8 to char.

card-setcos.c:

                /* Pin/key info: define 4 pins, no keys */
                if(file->path.len == 2)
                        pin_key_info = "\xC1\x04\x81\x82\x83\x84\xC2\x00";      
/* root-MF: use local pin-file */
                else
                        pin_key_info = "\xC1\x04\x01\x02\x03\x04\xC2\x00";      
/* sub-DF: use parent pin-file in root-MF */

well, we need to set those to unsigned char* strings. simply typecast them?


pkcs15-infocamere.c
set_string handles char strings. I wonder: when should our strings
be char, when should they be unsigned char? we have one warning about
serial, it can be changed into a char string to silence it for now.

pkcs15-gensafe.c
sc_pin_cmd_pin uses unsigned char for the pin, but the code uses
        char newpin[8];


uah, and there are lots of more warnings. if you add "-penantic" it explodes.
I think we should at least look at the "-O2 -g -Wall" warnings by gcc
3.3/3.4/4.0, fixing "-pedantic" too would be nice.

for the cases I mentioned, can you tell me what is the best way?
I don't want to flip coins to decide whether some struct should be
better char* or unsigned char*. is there some good rule to decide
that?

Regards, Andreas
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: warnings, signed issues, gcc 4.0

Nils Larsch
Andreas Jellinghaus wrote:
...
> opensc:
> reader-pcsc.c:984: warning: pointer targets in passing argument 3 of
> 'sc_bin_to_hex' differ in signedness

yep, dbuf in reader-pcsc.c should be of type char


> card-setcos.c:
>
>                 /* Pin/key info: define 4 pins, no keys */
>                 if(file->path.len == 2)
>                         pin_key_info = "\xC1\x04\x81\x82\x83\x84\xC2\x00";      
> /* root-MF: use local pin-file */
>                 else
>                         pin_key_info = "\xC1\x04\x01\x02\x03\x04\xC2\x00";      
> /* sub-DF: use parent pin-file in root-MF */
>
> well, we need to set those to unsigned char* strings. simply typecast them?

yep


>
>
> pkcs15-infocamere.c
> set_string handles char strings. I wonder: when should our strings
> be char, when should they be unsigned char? we have one warning about
> serial, it can be changed into a char string to silence it for now.

a simple (char *) cast should be safe here

>
> pkcs15-gensafe.c
> sc_pin_cmd_pin uses unsigned char for the pin, but the code uses
>         char newpin[8];

pin should be of type unsigned char, so using unsigned char alias
u8 should do it (and replacing "int" with "unsigned int" in is_seq
should remove some more warnings)

>
>
> uah, and there are lots of more warnings.

will you take care of it or should I do it ?

Nils
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel