int ret;
fp = hdopen(SYS_BLK "/%s/removable", d->d_name);
- if ((long)fp <= 0) {
- if ((long)fp < 0)
+ if (0 == (long)fp || -1 == (long)fp) {
+ if (-1 == (long)fp)
goto empty; /* error */
continue; /* no entry `removable' */
}
continue; /* should not happen */
fp = hdopen(SYS_CLASS "/%s/manage_start_stop", ptr);
- if ((long)fp <= 0) {
- if ((long)fp < 0)
+ if (0 == (long)fp || -1 == (long)fp) {
+ if (-1 == (long)fp)
goto empty; /* error */
} else {
ret = getc(fp);
}
fp = hdopen(SYS_BLK "/%s/device/vendor", d->d_name);
- if ((long)fp <= 0) {
- if ((long)fp < 0)
+ if (0 == (long)fp || -1 == (long)fp) {
+ if (-1 == (long)fp)
goto empty; /* error */
continue; /* no entry `device/vendor' */
}
}
/*
- * Open a sysfs file without getting a controlling tty
- * and return FILE* pointer.
+ * Open a sysfs file without getting a controlling tty and return
+ * FILE* pointer. Return 0 if the file didn't exist, or (FILE*)-1 if
+ * something else went wrong.
*/
static FILE *hdopen(const char* const format, const char* const name)
{
FILE *fp;
fp = hdopen(SYS_BLK "/%s/size", device);
- if ((long)fp <= 0) {
- if ((long)fp < 0)
+ if (0 == (long)fp || -1 == (long)fp) {
+ if (-1 == (long)fp)
return -1; /* error */
goto out; /* no entry `size' */
}