diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-05-06 17:02:40 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-05-06 17:02:40 +0100 |
commit | bcab5bb03e2944eeb96fb0948c61e175929d07a2 (patch) | |
tree | 9a4610f4aed6ade13578167614be982cbd2d85f3 /desktop/unx/source | |
parent | 9a7da369f73f3306ddd6ed050df3fcdc959742e2 (diff) |
coverity#1359235 Resource leak
Change-Id: I3f307211c70384b55b62314a7aa302ffcdfc7398
Diffstat (limited to 'desktop/unx/source')
-rw-r--r-- | desktop/unx/source/pagein.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/desktop/unx/source/pagein.c b/desktop/unx/source/pagein.c index 181637fc94e4..56baffa79ca3 100644 --- a/desktop/unx/source/pagein.c +++ b/desktop/unx/source/pagein.c @@ -46,27 +46,25 @@ static void do_pagein (const char * filename) int isRotational(char const * path) { + int ret = 1; #ifdef LINUX FILE * fp = NULL; char fullpath[4096]; struct stat out; int major, minor; char type; - if(stat( path , &out ) == -1) - return 1; + if (stat(path , &out) == -1) + return ret; major = major(out.st_dev); minor = 0; /* minor(out.st_dev); only the device itself has a queue */ sprintf(fullpath,"/sys/dev/block/%d:%d/queue/rotational",major,minor); - if ((fp = fopen (fullpath, "r"))) - { - if (fgets(&type, 1, fp)) - { - fclose(fp); - return type == '1'; - } - } + if ((fp = fopen(fullpath, "r")) == NULL) + return ret; + if (fgets(&type, 1, fp)) + ret = type == '1'; + fclose(fp); #endif - return 1; + return ret; } void pagein_execute(char const * path, char const * file) |