Module Name: src
Committed By: kiyohara
Date: Sun Dec 6 12:47:37 UTC 2009
Modified Files:
src/usr.sbin/btattach: btattach.c
Log Message:
Fix some bugs.
1. Remove O_NDELAY. Please block it. Or read() returns EAGAIN.
2. We want data size. header already read.
3. Call errx(). errno(2) unspecified at now.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/btattach/btattach.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/btattach/btattach.c
diff -u src/usr.sbin/btattach/btattach.c:1.3 src/usr.sbin/btattach/btattach.c:1.4
--- src/usr.sbin/btattach/btattach.c:1.3 Wed Apr 15 00:32:23 2009
+++ src/usr.sbin/btattach/btattach.c Sun Dec 6 12:47:37 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: btattach.c,v 1.3 2009/04/15 00:32:23 lukem Exp $ */
+/* $NetBSD: btattach.c,v 1.4 2009/12/06 12:47:37 kiyohara Exp $ */
/*-
* Copyright (c) 2008 Iain Hibbert
@@ -27,7 +27,7 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008 Iain Hibbert. All rights reserved.");
-__RCSID("$NetBSD: btattach.c,v 1.3 2009/04/15 00:32:23 lukem Exp $");
+__RCSID("$NetBSD: btattach.c,v 1.4 2009/12/06 12:47:37 kiyohara Exp $");
#include <sys/ioctl.h>
#include <sys/param.h>
@@ -211,7 +211,7 @@
init_speed = (type->speed ? type->speed : speed);
/* open tty */
- if ((fd = open(argv[0], O_RDWR | O_NDELAY | O_EXLOCK, 0)) < 0)
+ if ((fd = open(argv[0], O_RDWR | O_EXLOCK, 0)) < 0)
err(EXIT_FAILURE, "%s", argv[0]);
/* setup tty */
@@ -388,27 +388,24 @@
switch(type) {
case HCI_EVENT_PKT:
(void)uart_getc(fd, iov, ioc, &count); /* event */
- want = sizeof(hci_event_hdr_t);
- want += uart_getc(fd, iov, ioc, &count);
+ want = uart_getc(fd, iov, ioc, &count);
break;
case HCI_ACL_DATA_PKT:
(void)uart_getc(fd, iov, ioc, &count); /* handle LSB */
(void)uart_getc(fd, iov, ioc, &count); /* handle MSB */
- want = sizeof(hci_acldata_hdr_t);
- want += uart_getc(fd, iov, ioc, &count); /* LSB */
- want += uart_getc(fd, iov, ioc, &count) << 8; /* MSB */
+ want = uart_getc(fd, iov, ioc, &count) | /* LSB */
+ uart_getc(fd, iov, ioc, &count) << 8; /* MSB */
break;
case HCI_SCO_DATA_PKT:
(void)uart_getc(fd, iov, ioc, &count); /* handle LSB */
(void)uart_getc(fd, iov, ioc, &count); /* handle MSB */
- want = sizeof(hci_scodata_hdr_t);
- want += uart_getc(fd, iov, ioc, &count);
+ want = uart_getc(fd, iov, ioc, &count);
break;
default: /* out of sync? */
- err(EXIT_FAILURE, "unknown packet type 0x%2.2x", type);
+ errx(EXIT_FAILURE, "unknown packet type 0x%2.2x\n", type);
}
while (want-- > 0)