summaryrefslogtreecommitdiff
path: root/sys/dev/microcode/neomagic/build.c
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/neomagic/build.c
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/neomagic/build.c')
-rw-r--r--sys/dev/microcode/neomagic/build.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/sys/dev/microcode/neomagic/build.c b/sys/dev/microcode/neomagic/build.c
index 8b76aa39502..05dbea62624 100644
--- a/sys/dev/microcode/neomagic/build.c
+++ b/sys/dev/microcode/neomagic/build.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: build.c,v 1.1 2004/11/22 04:29:06 deraadt Exp $ */
+/* $OpenBSD: build.c,v 1.2 2005/05/17 18:48:52 jason Exp $ */
/*
* Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org>
@@ -17,6 +17,10 @@
*/
#include <sys/types.h>
#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <err.h>
#include <dev/pci/neoreg.h>
#include "neo-coeff.h"
@@ -26,8 +30,9 @@
int
main(int argc, char *argv[])
{
+ ssize_t rlen;
struct neo_firmware nf;
- int fd, i;
+ int fd;
fd = open(FILENAME, O_WRONLY|O_CREAT|O_TRUNC, 0644);
if (fd == -1)
@@ -38,7 +43,11 @@ main(int argc, char *argv[])
bcopy(coefficients, &nf.coefficients,
sizeof nf.coefficients);
- write(fd, &nf, sizeof nf);
+ rlen = write(fd, &nf, sizeof nf);
+ if (rlen == -1)
+ err(1, "%s", FILENAME);
+ if (rlen != sizeof nf)
+ errx(1, "%s: short write", FILENAME);
printf("created %s length %d\n", FILENAME, sizeof nf);
close(fd);
return (0);