]> code.delx.au - pulseaudio/commitdiff
Fix checking for NULL after usage
authorAndy Shevchenko <ext-andriy.shevchenko@nokia.com>
Fri, 28 Aug 2009 12:16:54 +0000 (15:16 +0300)
committerLennart Poettering <lennart@poettering.net>
Fri, 28 Aug 2009 15:12:44 +0000 (17:12 +0200)
The pa_xmalloc calls oom() in case of NULL pointer returned by malloc() on one
hand and dereferencing of pointer is happen early than actual check on other
hand. Thus, just remove useless checks.

src/pulse/ext-stream-restore.c
src/pulsecore/protocol-simple.c
src/pulsecore/resampler.c
src/pulsecore/sound-file-stream.c

index 63c911f805949b1d0d40fd2c4d2803d75dd0cf7c..10e9fd5dd5915310ea691da6c5e2f05c2ac86d07 100644 (file)
@@ -239,13 +239,10 @@ pa_operation *pa_ext_stream_restore_write(
     return o;
 
 fail:
-    if (o) {
-        pa_operation_cancel(o);
-        pa_operation_unref(o);
-    }
+    pa_operation_cancel(o);
+    pa_operation_unref(o);
 
-    if (t)
-        pa_tagstruct_free(t);
+    pa_tagstruct_free(t);
 
     pa_context_set_error(c, PA_ERR_INVALID);
     return NULL;
@@ -290,13 +287,10 @@ pa_operation *pa_ext_stream_restore_delete(
     return o;
 
 fail:
-    if (o) {
-        pa_operation_cancel(o);
-        pa_operation_unref(o);
-    }
+    pa_operation_cancel(o);
+    pa_operation_unref(o);
 
-    if (t)
-        pa_tagstruct_free(t);
+    pa_tagstruct_free(t);
 
     pa_context_set_error(c, PA_ERR_INVALID);
     return NULL;
index 95ec6ac8e41848ffc7ba7ad4f626b6fbebab1482..488d75721c53254df8111fe21880f2ffcab23f6f 100644 (file)
@@ -627,8 +627,7 @@ void pa_simple_protocol_connect(pa_simple_protocol *p, pa_iochannel *io, pa_simp
     return;
 
 fail:
-    if (c)
-        connection_unlink(c);
+    connection_unlink(c);
 }
 
 void pa_simple_protocol_disconnect(pa_simple_protocol *p, pa_module *m) {
index f1bfa156b54499a6f4f5918d391ed838d4864b9b..bed5a20dfbdabc888a50399f99a9bfdead8533e4 100644 (file)
@@ -299,8 +299,7 @@ pa_resampler* pa_resampler_new(
     return r;
 
 fail:
-    if (r)
-        pa_xfree(r);
+    pa_xfree(r);
 
     return NULL;
 }
index f41c53f3c8f86f7bc463ae24ba3874af034f674d..c4b4d1a5386c49a37a413307d1ada433ad14e126 100644 (file)
@@ -334,8 +334,7 @@ int pa_play_file(
     return 0;
 
 fail:
-    if (u)
-        file_stream_unref(u);
+    file_stream_unref(u);
 
     if (fd >= 0)
         pa_close(fd);