Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 May 2010 16:57:00 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r207620 - head/sys/dev/sound/pcm
Message-ID:  <201005041657.o44Gv0gC077891@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Tue May  4 16:56:59 2010
New Revision: 207620
URL: http://svn.freebsd.org/changeset/base/207620

Log:
  - Remove more dead code[1].  Since r207330, we only need to check division
  by zero of the second argument 'from'.
  - Prefer u_int32_t over unsigned int to make its intention more clearer.
  - Move the function to a header file and make it a static inline function.
  
  Pointed out by:	Andrew Reilly (areilly at bigpond dot net dot au)[1]
  MFC after:	3 days

Modified:
  head/sys/dev/sound/pcm/buffer.c
  head/sys/dev/sound/pcm/buffer.h

Modified: head/sys/dev/sound/pcm/buffer.c
==============================================================================
--- head/sys/dev/sound/pcm/buffer.c	Tue May  4 16:12:48 2010	(r207619)
+++ head/sys/dev/sound/pcm/buffer.c	Tue May  4 16:56:59 2010	(r207620)
@@ -566,19 +566,6 @@ sndbuf_updateprevtotal(struct snd_dbuf *
 }
 
 unsigned int
-snd_xbytes(unsigned int v, unsigned int from, unsigned int to)
-{
-
-	if (from == to)
-		return v;
-
-	if (from == 0 || to == 0 || v == 0)
-		return 0;
-
-	return (unsigned int)(((u_int64_t)v * to) / from);
-}
-
-unsigned int
 sndbuf_xbytes(unsigned int v, struct snd_dbuf *from, struct snd_dbuf *to)
 {
 	if (from == NULL || to == NULL || v == 0)

Modified: head/sys/dev/sound/pcm/buffer.h
==============================================================================
--- head/sys/dev/sound/pcm/buffer.h	Tue May  4 16:12:48 2010	(r207619)
+++ head/sys/dev/sound/pcm/buffer.h	Tue May  4 16:56:59 2010	(r207620)
@@ -111,7 +111,6 @@ u_int64_t sndbuf_getblocks(struct snd_db
 u_int64_t sndbuf_getprevblocks(struct snd_dbuf *b);
 u_int64_t sndbuf_gettotal(struct snd_dbuf *b);
 u_int64_t sndbuf_getprevtotal(struct snd_dbuf *b);
-unsigned int snd_xbytes(unsigned int v, unsigned int from, unsigned int to);
 unsigned int sndbuf_xbytes(unsigned int v, struct snd_dbuf *from, struct snd_dbuf *to);
 u_int8_t sndbuf_zerodata(u_int32_t fmt);
 void sndbuf_updateprevtotal(struct snd_dbuf *b);
@@ -132,3 +131,14 @@ void sndbuf_dmabounce(struct snd_dbuf *b
 #ifdef OSSV4_EXPERIMENT
 void sndbuf_getpeaks(struct snd_dbuf *b, int *lp, int *rp);
 #endif
+
+static inline u_int32_t
+snd_xbytes(u_int32_t v, u_int32_t from, u_int32_t to)
+{
+
+	if (from == to)
+		return (v);
+	if (from == 0)
+		return (0);
+	return ((u_int64_t)v * to / from);
+}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201005041657.o44Gv0gC077891>