[PATCH] remove redundant NULL checks before kfree() in sound/ and avoid casting point...
authorJesper Juhl <juhl-lkml@dif.dk>
Sat, 25 Jun 2005 21:58:49 +0000 (14:58 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 25 Jun 2005 23:25:00 +0000 (16:25 -0700)
Checking a pointer for NULL before calling kfree() on it is redundant,
kfree() deals with NULL pointers just fine.
This patch removes such checks from sound/

This patch also makes another, but closely related, change.
It avoids casting pointers about to be kfree()'ed.

Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
sound/oss/ad1848.c
sound/oss/ad1889.c
sound/oss/dmasound/dmasound_awacs.c
sound/oss/emu10k1/midi.c
sound/oss/emu10k1/passthrough.c
sound/oss/maestro.c
sound/oss/mpu401.c
sound/oss/sb_common.c

index 4384dac3f7949008285e71f94eec5123e27050b9..7c835abd99bc9ab2abc919b3cb8da9c48341004c 100644 (file)
@@ -2178,8 +2178,7 @@ void ad1848_unload(int io_base, int irq, int dma_playback, int dma_capture, int
                
        if (devc != NULL)
        {
-               if(audio_devs[dev]->portc!=NULL)
-                       kfree(audio_devs[dev]->portc);
+               kfree(audio_devs[dev]->portc);
                release_region(devc->base, 4);
 
                if (!share_dma)
index b767c621fd09060ebd5575e4b8a3a9382c69e0ea..2cfd214e4c2a42e0b48f6f4c134e131bc8a03166 100644 (file)
@@ -277,8 +277,7 @@ static void ad1889_free_dev(ad1889_dev_t *dev)
 
        for (j = 0; j < AD_MAX_STATES; j++) {
                dmabuf = &dev->state[j].dmabuf;
-               if (dmabuf->rawbuf != NULL) 
-                       kfree(dmabuf->rawbuf);
+               kfree(dmabuf->rawbuf);
        }
 
        kfree(dev);
index 5281b88987f35bc30f56c0bbe3b5633f24ec2116..33108661e671340d75a0a373fab0933525e86242 100644 (file)
@@ -671,14 +671,10 @@ static void PMacIrqCleanup(void)
        release_OF_resource(awacs_node, 1);
        release_OF_resource(awacs_node, 2);
 
-       if (awacs_tx_cmd_space)
-               kfree(awacs_tx_cmd_space);
-       if (awacs_rx_cmd_space)
-               kfree(awacs_rx_cmd_space);
-       if (beep_dbdma_cmd_space)
-               kfree(beep_dbdma_cmd_space);
-       if (beep_buf)
-               kfree(beep_buf);
+       kfree(awacs_tx_cmd_space);
+       kfree(awacs_rx_cmd_space);
+       kfree(beep_dbdma_cmd_space);
+       kfree(beep_buf);
 #ifdef CONFIG_PMAC_PBOOK
        pmu_unregister_sleep_notifier(&awacs_sleep_notifier);
 #endif
@@ -2301,8 +2297,7 @@ if (count <= 0)
 #endif
 
        if ((write_sq.max_count + 1) > number_of_tx_cmd_buffers) {
-               if (awacs_tx_cmd_space)
-                       kfree(awacs_tx_cmd_space);
+               kfree(awacs_tx_cmd_space);
                number_of_tx_cmd_buffers = 0;
 
                /* we need nbufs + 1 (for the loop) and we should request + 1
@@ -2360,8 +2355,7 @@ if (count <= 0)
 #endif
 
        if ((read_sq.max_count+1) > number_of_rx_cmd_buffers ) {
-               if (awacs_rx_cmd_space)
-                       kfree(awacs_rx_cmd_space);
+               kfree(awacs_rx_cmd_space);
                number_of_rx_cmd_buffers = 0;
 
                /* we need nbufs + 1 (for the loop) and we should request + 1 again
@@ -2805,7 +2799,7 @@ __init setup_beep(void)
        beep_buf = (short *) kmalloc(BEEP_BUFLEN * 4, GFP_KERNEL);
        if (beep_buf == NULL) {
                printk(KERN_ERR "dmasound_pmac: no memory for beep buffer\n");
-               if( beep_dbdma_cmd_space ) kfree(beep_dbdma_cmd_space) ;
+               kfree(beep_dbdma_cmd_space) ;
                return -ENOMEM ;
        }
        return 0 ;
index 33dea3d56c1e138bdc461e8f255bce857104766a..b40b5f97aacea3a5240b845e10745dcc77c22cf3 100644 (file)
@@ -523,10 +523,8 @@ void emu10k1_seq_midi_close(int dev)
        card = midi_devs[dev]->devc;
        emu10k1_mpuout_close(card);
 
-       if (card->seq_mididev) {
-               kfree(card->seq_mididev);
-               card->seq_mididev = NULL;
-       }
+       kfree(card->seq_mididev);
+       card->seq_mididev = NULL;
 }
 
 int emu10k1_seq_midi_out(int dev, unsigned char midi_byte)
index 4094be55f3be335338fd120224a0fba22c6ce711..4e3baca7d41f3d2856accd469e0292d749a07e47 100644 (file)
@@ -213,8 +213,7 @@ void emu10k1_pt_stop(struct emu10k1_card *card)
                                sblive_writeptr(card, SPCS0 + i, 0, pt->old_spcs[i]);
                }
                pt->state = PT_STATE_INACTIVE;
-               if(pt->buf)
-                       kfree(pt->buf);
+               kfree(pt->buf);
        }
 }
 
index 52d2db4bc312fadeddff95c9f1d8d0f3fba80823..3dce504e6d6d764ee330e47392238553e7fccf8a 100644 (file)
@@ -2356,7 +2356,7 @@ ess_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
        }
 
 rec_return_free:
-       if(combbuf) kfree(combbuf);
+       kfree(combbuf);
        return ret;
 }
 
index b66f53fa8db03ca57296ba6ea091579440f82639..0aac54c68f01fa13c124ee5715c4f6f0b9b23124 100644 (file)
@@ -1240,8 +1240,7 @@ void unload_mpu401(struct address_info *hw_config)
                p=mpu401_synth_operations[n];
                sound_unload_mididev(n);
                sound_unload_timerdev(hw_config->slots[2]);
-               if(p)
-                       kfree(p);
+               kfree(p);
        }
 }
 
index ce359e6c933aa0ae3962a202e2c253492899093d..5f955e3d2e26926e6e59612416466d78bced3db3 100644 (file)
@@ -915,8 +915,8 @@ void sb_dsp_unload(struct address_info *hw_config, int sbmpu)
        }
        else
                release_region(hw_config->io_base, 16);
-       if(detected_devc)
-               kfree(detected_devc);
+
+       kfree(detected_devc);
 }
 
 /*