sync to openbsd (s/fprintf/errx, usage, etc)

This commit is contained in:
Alexandre Ratchov 2012-08-30 10:04:20 +02:00
parent e7eab266fa
commit a268087ed6
4 changed files with 24 additions and 37 deletions

View File

@ -429,17 +429,15 @@ main(int argc, char **argv)
else else
prog++; prog++;
if (strcmp(prog, PROG_AUCAT) == 0) { if (strcmp(prog, PROG_AUCAT) == 0) {
optstr = "a:b:c:C:de:f:h:i:j:lL:m:Mno:q:r:s:t:U:v:w:x:z:"; optstr = "b:c:C:de:f:h:i:j:m:no:q:r:t:v:w:x:z:";
usagestr = aucat_usage; usagestr = aucat_usage;
} else if (strcmp(prog, PROG_SNDIOD) == 0) { } else if (strcmp(prog, PROG_SNDIOD) == 0) {
optstr = "a:b:c:C:de:f:j:L:m:Mq:r:s:t:U:v:w:x:z:"; optstr = "a:b:c:C:de:f:j:L:m:Mq:r:s:t:U:v:w:x:z:";
usagestr = sndiod_usage; usagestr = sndiod_usage;
background = 1; background = 1;
hold = 0; hold = 0;
} else { } else
fprintf(stderr, "%s: can't determine program to run\n", prog); errx(1, "%s: can't determine program to run", prog);
return 1;
}
while ((c = getopt(argc, argv, optstr)) != -1) { while ((c = getopt(argc, argv, optstr)) != -1) {
switch (c) { switch (c) {
@ -553,9 +551,6 @@ main(int argc, char **argv)
case 'M': case 'M':
mkdev("midithru", MODE_THRU, 0, 0, hold, 0); mkdev("midithru", MODE_THRU, 0, 0, hold, 0);
break; break;
case 'l':
background = 1;
break;
default: default:
fputs(usagestr, stderr); fputs(usagestr, stderr);
exit(1); exit(1);

View File

@ -373,7 +373,12 @@ dev_open(struct dev *d)
d->ipar = par; d->ipar = par;
d->opar = par; d->opar = par;
d->rate = rate; d->rate = rate;
d->round = rate; /*
* block sizes in the resampling code are limited to
* 2^15, so use 1/15 of the rate, since all standard
* sample rates are multiple of 15
*/
d->round = rate / 15;
d->bufsz = 2 * d->round; d->bufsz = 2 * d->round;
} }
#ifdef DEBUG #ifdef DEBUG

View File

@ -62,10 +62,8 @@ listen_new_un(char *path)
struct listen *f; struct listen *f;
sock = socket(AF_UNIX, SOCK_STREAM, 0); sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock < 0) { if (sock < 0)
perror("socket"); err(1, "socket");
exit(1);
}
if (unlink(path) < 0 && errno != ENOENT) { if (unlink(path) < 0 && errno != ENOENT) {
perror("unlink"); perror("unlink");
goto bad_close; goto bad_close;
@ -83,10 +81,8 @@ listen_new_un(char *path)
if (f == NULL) if (f == NULL)
goto bad_close; goto bad_close;
f->path = strdup(path); f->path = strdup(path);
if (f->path == NULL) { if (f->path == NULL)
perror("strdup"); err(1, "strdup");
exit(1);
}
f->fd = sock; f->fd = sock;
f->next = listen_list; f->next = listen_list;
listen_list = f; listen_list = f;
@ -114,10 +110,8 @@ listen_new_tcp(char *addr, unsigned int port)
aihints.ai_socktype = SOCK_STREAM; aihints.ai_socktype = SOCK_STREAM;
aihints.ai_protocol = IPPROTO_TCP; aihints.ai_protocol = IPPROTO_TCP;
error = getaddrinfo(host, serv, &aihints, &ailist); error = getaddrinfo(host, serv, &aihints, &ailist);
if (error) { if (error)
fprintf(stderr, "%s: %s\n", addr, gai_strerror(error)); errx(1, "%s: %s", addr, gai_strerror(error));
exit(1);
}
/* /*
* for each address, try create a listening socket bound on * for each address, try create a listening socket bound on

View File

@ -14,6 +14,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
#include <err.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -37,22 +38,16 @@ opt_new(char *name, struct dev *dev,
char c; char c;
for (len = 0; name[len] != '\0'; len++) { for (len = 0; name[len] != '\0'; len++) {
if (len == OPT_NAMEMAX) { if (len == OPT_NAMEMAX)
fprintf(stderr, "%s: name too long\n", name); errx(1, "%s: name too long", name);
exit(1);
}
c = name[len]; c = name[len];
if ((c < 'a' || c > 'z') && if ((c < 'a' || c > 'z') &&
(c < 'A' || c > 'Z')) { (c < 'A' || c > 'Z'))
fprintf(stderr, "%s: '%c' not allowed\n", name, c); errx(1, "%s: '%c' not allowed", name, c);
exit(1);
}
} }
o = malloc(sizeof(struct opt)); o = malloc(sizeof(struct opt));
if (o == NULL) { if (o == NULL)
perror("opt_new: malloc"); err(1, "opt_new: malloc");
exit(1);
}
if (mode & MODE_RECMASK) if (mode & MODE_RECMASK)
o->wpar = (mode & MODE_MON) ? *rpar : *wpar; o->wpar = (mode & MODE_MON) ? *rpar : *wpar;
if (mode & MODE_PLAY) if (mode & MODE_PLAY)
@ -65,10 +60,8 @@ opt_new(char *name, struct dev *dev,
memcpy(o->name, name, len + 1); memcpy(o->name, name, len + 1);
for (po = &opt_list; *po != NULL; po = &(*po)->next) { for (po = &opt_list; *po != NULL; po = &(*po)->next) {
if (o->dev->num == (*po)->dev->num && if (o->dev->num == (*po)->dev->num &&
strcmp(o->name, (*po)->name) == 0) { strcmp(o->name, (*po)->name) == 0)
fprintf(stderr, "%s: already defined\n", o->name); errx(1, "%s: already defined", o->name);
exit(1);
}
} }
o->next = NULL; o->next = NULL;
*po = o; *po = o;