diff options
-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) |