2011/3/23 Viktor TARASOV <viktor.tara...@opentrust.com>:
> Le 23/03/2011 16:29, Ludovic Rousseau a écrit :
>>
>> Hello,
>>
>> I get this:
>> pkcs15-iasecc.c: In function ‘iasecc_file_convert_acls’:
>> pkcs15-iasecc.c:312: warning: initialization discards qualifiers from
>> pointer target type
>>
>> The problem is the line:
>>                struct sc_acl_entry *acl = sc_file_get_acl_entry(file, ii);
>>
>> If I change it to:
>>                const struct sc_acl_entry *acl =
>> sc_file_get_acl_entry(file, ii);
>> I then get errors:
>> pkcs15-iasecc.c: In function ‘iasecc_file_convert_acls’:
>> pkcs15-iasecc.c:320: error: assignment of read-only location
>> pkcs15-iasecc.c:321: error: assignment of read-only location
>> pkcs15-iasecc.c:324: error: assignment of read-only location
>> pkcs15-iasecc.c:325: error: assignment of read-only location
>>
>> This is because the iasecc_file_convert_acls() function _does_ change
>> the (const) structure returned by sc_file_get_acl_entry().
>>
>> Complete function:
>
> ...
>>
>> I don't know what is the proper way to fix this.
>
> Remove 'cost' qualifier from the function prototype, like in attachment ?

No. You can't do that.
The function may also return a pointer to a static variable allocated
by the function sc_file_get_acl_entry(). The caller shall not modify
the static variable allocated by the called function.

Maybe the idea if hardcode special values for never, none and unknown
into a pointer is a bad idea. Is it just to save a few bytes of RAM?

-- 
 Dr. Ludovic Rousseau
_______________________________________________
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Reply via email to