X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=panel-plugin%2Fhdaps.c;h=4254d720ca822660b5e0d683d53542cfc9f322ba;hb=60ffd1d1b7266d9a030b2c864135ff444f0cb917;hp=c9a6831e00fe96207dafca5302bfb31dbc94ee92;hpb=c2192722c30e86449a7598eb9c962af39ed2a7e0;p=xfce4-hdaps.git diff --git a/panel-plugin/hdaps.c b/panel-plugin/hdaps.c index c9a6831..4254d72 100644 --- a/panel-plugin/hdaps.c +++ b/panel-plugin/hdaps.c @@ -58,13 +58,13 @@ int get_hdaps_device_list(char list[MAX_HDAPS_DEVICES][FILENAME_MAX]) { * We start by getting every device in the sysfs * block device directory, and then eliminate those * which don't have an unload_heads entry. - */ + */ int list_idx = 0; DIR *dp; struct dirent *ep; dp = opendir(SYSFS_BLOCK_DEVICE_DIR); - + if (dp != NULL) { while ((ep = readdir(dp)) && list_idx < MAX_HDAPS_DEVICES) { /* This next test covers "." and ".." too. */ @@ -85,26 +85,26 @@ int get_hdaps_device_list(char list[MAX_HDAPS_DEVICES][FILENAME_MAX]) { int slurp_file(const char* filename, char* buf, int max_bytes) { /* This function just reads the contents of filename * into buf, and returns the number of bytes read. - */ + */ if (filename == NULL || buf == NULL) { /* HDAPS_SUPER_BAD_ERROR */ return HDAPS_ERROR; } - + /* Return an error value by default. */ int bytes_read = HDAPS_ERROR; int fd = open(filename, O_RDONLY); - + if (fd < 0) { /* open() didn't work. Report the error, and bail. */ fprintf(stderr, "open(%s): %s\n", filename, strerror(errno)); return HDAPS_ERROR; - } + } bytes_read = read(fd, buf, max_bytes-1); - + if (bytes_read < 0) { /* Why did we read fewer than 0 bytes? */ fprintf(stderr, "read(%s): %s\n", filename, strerror(errno)); @@ -113,13 +113,13 @@ int slurp_file(const char* filename, char* buf, int max_bytes) { /* Null-terminate buf if read() worked. */ buf[bytes_read] = 0; } - + if (close(fd)) { /* Oh hey we should be able to close the file, too. */ - fprintf(stderr, "close(%s): %s\n", filename, strerror(errno)); + fprintf(stderr, "close(%s): %s\n", filename, strerror(errno)); } - + return bytes_read; } @@ -129,7 +129,7 @@ int slurp_file(const char* filename, char* buf, int max_bytes) { int parse_int_from_file(const char* filename) { /* Read an integer from a file. We expect the file to contain an integer (although in string form). */ - + char buf[MAX_FILE_CONTENTS_SIZE]; int bytes_read = slurp_file(filename, buf, sizeof(buf));