Initialise polFd to -1 before hand to avoid closing 0 by accident.
Also fixed some style problems while I was there.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
int main_loadpolicy(int argc, char **argv)
{
const char *polFName;
- int polFd = 0;
+ int polFd = -1;
void *polMemCp = NULL;
struct stat info;
int ret;
polFName = argv[optind];
polFd = open(polFName, O_RDONLY);
- if ( polFd < 0 ) {
+ if (polFd < 0) {
fprintf(stderr, "Error occurred opening policy file '%s': %s\n",
polFName, strerror(errno));
ret = -1;
}
ret = stat(polFName, &info);
- if ( ret < 0 ) {
+ if (ret < 0) {
fprintf(stderr, "Error occurred retrieving information about"
"policy file '%s': %s\n", polFName, strerror(errno));
goto done;
done:
free(polMemCp);
- if ( polFd > 0 )
+ if (polFd >= 0)
close(polFd);
return ret;