OSDN Git Service

tools: Fix build error in seq2bseq
authorSzymon Janc <szymon.janc@tieto.com>
Mon, 13 Jan 2014 08:09:13 +0000 (09:09 +0100)
committerJohan Hedberg <johan.hedberg@intel.com>
Mon, 13 Jan 2014 08:47:36 +0000 (10:47 +0200)
Don't ignore return value of write. This fix following build error on
Ubuntu:

tools/seq2bseq.c: In function ‘convert_line’:
tools/seq2bseq.c:52:8: error: ignoring return value of ‘write’,
     declared with attribute warn_unused_result [-Werror=unused-result]
   write(fd, &val, 1);

tools/seq2bseq.c

index 6d70777..9797f5f 100644 (file)
 #include <string.h>
 #include <stdlib.h>
 #include <getopt.h>
+#include <errno.h>
 #include <sys/stat.h>
 
-static void convert_line(int fd, const char *line)
+static int convert_line(int fd, const char *line)
 {
        const char *ptr = line;
        char str[3];
        unsigned char val;
 
        if (line[0] == '*' || line[0] == '\r' || line[0] == '\r')
-               return;
+               return 0;
 
        while (1) {
                str[0] = *ptr++;
@@ -49,7 +50,8 @@ static void convert_line(int fd, const char *line)
 
                val = strtol(str, NULL, 16);
 
-               write(fd, &val, 1);
+               if (write(fd, &val, 1) < 0)
+                       return -errno;
 
                if (*ptr == '\r' || *ptr == '\n')
                        break;
@@ -57,6 +59,8 @@ static void convert_line(int fd, const char *line)
                while (*ptr == ' ')
                        ptr++;
        }
+
+       return 0;
 }
 
 static void convert_file(const char *input_path, const char *output_path)