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);
#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++;
val = strtol(str, NULL, 16);
- write(fd, &val, 1);
+ if (write(fd, &val, 1) < 0)
+ return -errno;
if (*ptr == '\r' || *ptr == '\n')
break;
while (*ptr == ' ')
ptr++;
}
+
+ return 0;
}
static void convert_file(const char *input_path, const char *output_path)