From b972436577589cbf5796f477c17c357efe73dc81 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Sun, 26 Jul 2009 13:33:31 +0000 Subject: use ``sizeof(string) - 1'' rather than ``strlen(string)'' on static strings. suggested by Thomas Pfaff --- lib/libsndio/mio.c | 6 +++--- lib/libsndio/mio_priv.h | 4 ++-- lib/libsndio/sndio.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/libsndio/mio.c b/lib/libsndio/mio.c index 6064981eb6f..4e423bebd17 100644 --- a/lib/libsndio/mio.c +++ b/lib/libsndio/mio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mio.c,v 1.4 2009/07/26 13:10:05 ratchov Exp $ */ +/* $OpenBSD: mio.c,v 1.5 2009/07/26 13:33:30 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov * @@ -79,10 +79,10 @@ mio_open(const char *str, unsigned mode, int nbio) } len = sep - str; - if (len == strlen(prefix_midithru) && + if (len == (sizeof(prefix_midithru) - 1) && memcmp(str, prefix_midithru, len) == 0) return mio_open_thru(sep + 1, mode, nbio); - if (len == strlen(prefix_rmidi) && + if (len == (sizeof(prefix_rmidi) - 1) && memcmp(str, prefix_rmidi, len) == 0) return mio_open_rmidi(sep + 1, mode, nbio); DPRINTF("mio_open: %s: unknown device type\n", str); diff --git a/lib/libsndio/mio_priv.h b/lib/libsndio/mio_priv.h index e5c76553888..ec217394cc4 100644 --- a/lib/libsndio/mio_priv.h +++ b/lib/libsndio/mio_priv.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mio_priv.h,v 1.2 2009/07/25 11:15:56 ratchov Exp $ */ +/* $OpenBSD: mio_priv.h,v 1.3 2009/07/26 13:33:30 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov * @@ -41,7 +41,7 @@ */ struct mio_hdl { struct mio_ops *ops; - unsigned mode; /* MIO_PLAY | MIO_REC */ + unsigned mode; /* MIO_IN | MIO_OUT */ int nbio; /* true if non-blocking io */ int eof; /* true if error occured */ }; diff --git a/lib/libsndio/sndio.c b/lib/libsndio/sndio.c index dcb770d45d0..f50d871b793 100644 --- a/lib/libsndio/sndio.c +++ b/lib/libsndio/sndio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sndio.c,v 1.18 2009/07/26 12:38:20 ratchov Exp $ */ +/* $OpenBSD: sndio.c,v 1.19 2009/07/26 13:33:30 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov * @@ -212,10 +212,10 @@ sio_open(const char *str, unsigned mode, int nbio) return sio_open_sun(buf, mode, nbio); } len = sep - str; - if (len == strlen(prefix_aucat) && + if (len == (sizeof(prefix_aucat) - 1) && memcmp(str, prefix_aucat, len) == 0) return sio_open_aucat(sep + 1, mode, nbio); - if (len == strlen(prefix_sun) && + if (len == (sizeof(prefix_sun) - 1) && memcmp(str, prefix_sun, len) == 0) return sio_open_sun(sep + 1, mode, nbio); DPRINTF("sio_open: %s: unknown device type\n", str); -- cgit v1.2.3