Fix SVACE defects 44/188944/2 accepted/tizen/unified/20180912.153358 submit/tizen/20180912.045643 submit/tizen/20180912.073953
authorDongsun Lee <ds73.lee@samsung.com>
Wed, 12 Sep 2018 04:14:00 +0000 (13:14 +0900)
committerDongsun Lee <ds73.lee@samsung.com>
Wed, 12 Sep 2018 04:18:35 +0000 (13:18 +0900)
- 325773 : ignoring return value of 'fread', declared with attribute warn_unused_result
- 347249 : format '%ld' expects argument of type 'long int'

Change-Id: I8ec62253afb4649cc7d8a4c810bcba5b5b03ad84
Signed-off-by: Dongsun Lee <ds73.lee@samsung.com>
tests/example_capi.c
tools/bin2c.c

index 3008730..cf5540e 100644 (file)
@@ -49,7 +49,7 @@ int main(int argc, char ** argv)
                printf("Can't get cert chain\n");
                goto exit;
        }
-       printf("Cert is %ld bytes\n", cert_chain_len);
+       printf("Cert is %d bytes\n", cert_chain_len);
        printf("Received cert %s\n", cert_chain);
 
        result = dcm_get_key_bit_length(key_ctx, &key_len);
index 73cad38..b49e4b4 100644 (file)
@@ -33,9 +33,14 @@ int main(int argc, char** argv) {
 
        char * buffer = (char *)malloc(size);
 
-       fread(buffer, 1, size, infile);
+       size_t readno = fread(buffer, 1, size, infile);
        fclose(infile);
 
+       if(readno <= 0) {
+               printf("Fail to read a file(%s)", argv[1]);
+               return -1;
+       }
+
        fprintf(outfile, "#include <sys/types.h>\nsize_t %s_size = %zd;\nunsigned char %s[]= {\n",
                        argv[3], size, argv[3]);