pkcs15-init: coverity scan warning NEGATIVE-RETURNS

CID 402540: Argument cannot be negative (NEGATIVE_RETURNS)
This commit is contained in:
Viktor Tarasov 2012-06-11 21:28:37 +02:00
parent 61254f8651
commit d3dbe444e1
1 changed files with 10 additions and 7 deletions

View File

@ -2130,18 +2130,21 @@ do_read_certificate(const char *name, const char *format, X509 **out)
return 0;
}
static int determine_filesize(const char *filename)
static size_t determine_filesize(const char *filename)
{
FILE *fp;
size_t size;
long ll;
if ((fp = fopen(filename,"rb")) == NULL)
util_fatal("Unable to open %s: %m", filename);
if ((fp = fopen(filename,"rb")) == NULL) {
util_fatal("Unable to open %s: %m", filename);
}
fseek(fp,0L,SEEK_END);
size = ftell(fp);
ll = ftell(fp);
if (ll == -1l)
util_fatal("fseek/ftell error");
fclose(fp);
return size;
return (size_t)ll;
}
static int