summaryrefslogtreecommitdiff
path: root/sys/dev/microcode/kue
diff options
context:
space:
mode:
authorJason Wright <jason@cvs.openbsd.org>2005-05-17 18:48:53 +0000
committerJason Wright <jason@cvs.openbsd.org>2005-05-17 18:48:53 +0000
commitef9da74a3a85403b02a5cccc664dd784d8fd4279 (patch)
tree4efe4dece78a33358d376f9c897bb5809afe155e /sys/dev/microcode/kue
parente9fcc6219571e8e6318ebd29c06ddb2f9833431a (diff)
- check return from write(2) so we KNOW the data is on the disk
- remove unneeded variables - add missing includes ok deraadt
Diffstat (limited to 'sys/dev/microcode/kue')
-rw-r--r--sys/dev/microcode/kue/build.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/sys/dev/microcode/kue/build.c b/sys/dev/microcode/kue/build.c
index 2b101b5b427..892773e3f59 100644
--- a/sys/dev/microcode/kue/build.c
+++ b/sys/dev/microcode/kue/build.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: build.c,v 1.2 2004/11/22 20:47:48 deraadt Exp $ */
+/* $OpenBSD: build.c,v 1.3 2005/05/17 18:48:52 jason Exp $ */
/*
* Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org>
@@ -19,7 +19,10 @@
#include <dev/usb/if_kuevar.h>
#include <fcntl.h>
#include <stdlib.h>
-
+#include <err.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
#include "kue_fw.h"
#define FILENAME "kue"
@@ -28,7 +31,8 @@ int
main(int argc, char *argv[])
{
struct kue_firmware kfproto, *kf;
- int len, fd, i;
+ int len, fd;
+ ssize_t rlen;
len = sizeof(*kf) - sizeof(kfproto.data) +
sizeof(kue_code_seg) + sizeof(kue_fix_seg) +
@@ -52,7 +56,11 @@ main(int argc, char *argv[])
if (fd == -1)
err(1, FILENAME);
- write(fd, kf, len);
+ rlen = write(fd, kf, len);
+ if (rlen == -1)
+ err(1, "%s", FILENAME);
+ if (rlen != len)
+ errx(1, "%s: short write", FILENAME);
free(kf);
close(fd);
return 0;