[PATCH 2/4] sound/oss: use unsigned for loop index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Julia Lawall <julia@xxxxxxx>

A few more cases in the spirit of the patch "Trivial: Replacement of always
>0 ints with unsigned ints" submitted by Ricardo Martins <ricardo@xxxxxxxxxxxx>

The transformation was made using the following semantic patch
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r exists@ // find anything that might decrement the variable
identifier i;
expression E;
position p;
@@

  int i@p;
  ...
(
  &i
|
  i--
|
  --i
|
  i-=E
|
  i+=E
)

@x disable decl_init@
identifier r.i;
expression E;
position p1 != r.p;
@@

(
  volatile int i = 0;
|
  volatile int i;
|
+ unsigned
  int i@p1 = 0;
|
+ unsigned
  int i@p1;
)
  <... when != i = E      
(
  i = 0
|
  i = 1
)
  ...>
// </smpl>

Signed-off-by: Julia Lawall <julia@xxxxxxx>

---

 sound/oss/dmasound/dmasound_core.c |    2 +-
 sound/oss/msnd.c                   |    4 ++--
 sound/oss/sb_common.c              |    6 +++---
 sound/oss/waveartist.c             |    4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff -u -p a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c
--- a/sound/oss/dmasound/dmasound_core.c 2008-04-07 13:50:28.000000000 +0200
+++ b/sound/oss/dmasound/dmasound_core.c 2008-05-11 12:19:29.000000000 +0200
@@ -423,7 +423,7 @@ static int sq_allocate_buffers(struct so
 
 static void sq_release_buffers(struct sound_queue *sq)
 {
-	int i;
+	unsigned int i;
 
 	if (sq->buffers) {
 		for (i = 0; i < sq->numBufs; i++)
diff -u -p a/sound/oss/msnd.c b/sound/oss/msnd.c
--- a/sound/oss/msnd.c 2008-04-07 13:50:28.000000000 +0200
+++ b/sound/oss/msnd.c 2008-05-11 12:19:27.000000000 +0200
@@ -49,7 +49,7 @@ static int			num_devs;
 
 int msnd_register(multisound_dev_t *dev)
 {
-	int i;
+	unsigned int i;
 
 	for (i = 0; i < MSND_MAX_DEVS; ++i)
 		if (devs[i] == NULL)
@@ -65,7 +65,7 @@ int msnd_register(multisound_dev_t *dev)
 
 void msnd_unregister(multisound_dev_t *dev)
 {
-	int i;
+	unsigned int i;
 
 	for (i = 0; i < MSND_MAX_DEVS; ++i)
 		if (devs[i] == dev)
diff -u -p a/sound/oss/sb_common.c b/sound/oss/sb_common.c
--- a/sound/oss/sb_common.c 2008-04-16 13:28:05.000000000 +0200
+++ b/sound/oss/sb_common.c 2008-05-11 12:19:36.000000000 +0200
@@ -84,7 +84,7 @@ static sb_devc *last_sb;		/* Last sb loa
 
 int sb_dsp_command(sb_devc * devc, unsigned char val)
 {
-	int i;
+	unsigned int i;
 	unsigned long limit;
 
 	limit = jiffies + HZ / 10;	/* Timeout */
@@ -600,7 +600,7 @@ int sb_dsp_detect(struct address_info *h
 			if (sb_dsp_command(devc, 0x09))
 				if (sb_dsp_command(devc, 0x00))	/* Enter WSS mode */
 				{
-					int i;
+					unsigned int i;
 
 					/* Have some delay */
 					for (i = 0; i < 10000; i++)
@@ -1009,7 +1009,7 @@ static int smw_midi_init(sb_devc * devc,
 {
 	int mpu_base = hw_config->io_base;
 	int mp_base = mpu_base + 4;		/* Microcontroller base */
-	int i;
+	unsigned int i;
 	unsigned char control;
 
 
diff -u -p a/sound/oss/waveartist.c b/sound/oss/waveartist.c
--- a/sound/oss/waveartist.c 2008-04-16 13:28:05.000000000 +0200
+++ b/sound/oss/waveartist.c 2008-05-11 12:19:27.000000000 +0200
@@ -1212,7 +1212,7 @@ static struct mixer_operations waveartis
 static void
 waveartist_mixer_reset(wavnc_info *devc)
 {
-	int i;
+	unsigned int i;
 
 	if (debug_flg & DEBUG_MIXER)
 		printk("%s: mixer_reset\n", devc->hw.name);
@@ -1417,7 +1417,7 @@ attach_waveartist(struct address_info *h
 static void __exit unload_waveartist(struct address_info *hw)
 {
 	wavnc_info *devc = NULL;
-	int i;
+	unsigned int i;
 
 	for (i = 0; i < nr_waveartist_devs; i++)
 		if (hw->io_base == adev_info[i].hw.io_base) {
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux