diff options
author | Peter Senna Tschudin <peter.senna@gmail.com> | 2012-09-12 07:56:04 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-10-06 10:07:34 -0400 |
commit | 3f037426d61027d40063a1fc2d00a08154c7c187 (patch) | |
tree | b68d4ecba154ba99428653826e1ad56ef5ef1fd0 | |
parent | 5f49908adb1ff4f0cec429923f1f49e79f318812 (diff) |
[media] drivers/media/dvb-frontends/dvb_dummy_fe.c: Removes useless kfree()
Remove useless kfree() and clean up code related to the removal.
The semantic patch that finds this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r exists@
position p1,p2;
expression x;
@@
if (x@p1 == NULL) { ... kfree@p2(x); ... return ...; }
@unchanged exists@
position r.p1,r.p2;
expression e <= r.x,x,e1;
iterator I;
statement S;
@@
if (x@p1 == NULL) { ... when != I(x,...) S
when != e = e1
when != e += e1
when != e -= e1
when != ++e
when != --e
when != e++
when != e--
when != &e
kfree@p2(x); ... return ...; }
@ok depends on unchanged exists@
position any r.p1;
position r.p2;
expression x;
@@
... when != true x@p1 == NULL
kfree@p2(x);
@depends on !ok && unchanged@
position r.p2;
expression x;
@@
*kfree@p2(x);
// </smpl>
Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/dvb-frontends/dvb_dummy_fe.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/drivers/media/dvb-frontends/dvb_dummy_fe.c b/drivers/media/dvb-frontends/dvb_dummy_fe.c index dcfc902c8678..d5acc304786b 100644 --- a/drivers/media/dvb-frontends/dvb_dummy_fe.c +++ b/drivers/media/dvb-frontends/dvb_dummy_fe.c | |||
@@ -121,16 +121,13 @@ struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void) | |||
121 | 121 | ||
122 | /* allocate memory for the internal state */ | 122 | /* allocate memory for the internal state */ |
123 | state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); | 123 | state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); |
124 | if (state == NULL) goto error; | 124 | if (!state) |
125 | return NULL; | ||
125 | 126 | ||
126 | /* create dvb_frontend */ | 127 | /* create dvb_frontend */ |
127 | memcpy(&state->frontend.ops, &dvb_dummy_fe_ofdm_ops, sizeof(struct dvb_frontend_ops)); | 128 | memcpy(&state->frontend.ops, &dvb_dummy_fe_ofdm_ops, sizeof(struct dvb_frontend_ops)); |
128 | state->frontend.demodulator_priv = state; | 129 | state->frontend.demodulator_priv = state; |
129 | return &state->frontend; | 130 | return &state->frontend; |
130 | |||
131 | error: | ||
132 | kfree(state); | ||
133 | return NULL; | ||
134 | } | 131 | } |
135 | 132 | ||
136 | static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops; | 133 | static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops; |
@@ -141,16 +138,13 @@ struct dvb_frontend *dvb_dummy_fe_qpsk_attach(void) | |||
141 | 138 | ||
142 | /* allocate memory for the internal state */ | 139 | /* allocate memory for the internal state */ |
143 | state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); | 140 | state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); |
144 | if (state == NULL) goto error; | 141 | if (!state) |
142 | return NULL; | ||
145 | 143 | ||
146 | /* create dvb_frontend */ | 144 | /* create dvb_frontend */ |
147 | memcpy(&state->frontend.ops, &dvb_dummy_fe_qpsk_ops, sizeof(struct dvb_frontend_ops)); | 145 | memcpy(&state->frontend.ops, &dvb_dummy_fe_qpsk_ops, sizeof(struct dvb_frontend_ops)); |
148 | state->frontend.demodulator_priv = state; | 146 | state->frontend.demodulator_priv = state; |
149 | return &state->frontend; | 147 | return &state->frontend; |
150 | |||
151 | error: | ||
152 | kfree(state); | ||
153 | return NULL; | ||
154 | } | 148 | } |
155 | 149 | ||
156 | static struct dvb_frontend_ops dvb_dummy_fe_qam_ops; | 150 | static struct dvb_frontend_ops dvb_dummy_fe_qam_ops; |
@@ -161,16 +155,13 @@ struct dvb_frontend *dvb_dummy_fe_qam_attach(void) | |||
161 | 155 | ||
162 | /* allocate memory for the internal state */ | 156 | /* allocate memory for the internal state */ |
163 | state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); | 157 | state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); |
164 | if (state == NULL) goto error; | 158 | if (!state) |
159 | return NULL; | ||
165 | 160 | ||
166 | /* create dvb_frontend */ | 161 | /* create dvb_frontend */ |
167 | memcpy(&state->frontend.ops, &dvb_dummy_fe_qam_ops, sizeof(struct dvb_frontend_ops)); | 162 | memcpy(&state->frontend.ops, &dvb_dummy_fe_qam_ops, sizeof(struct dvb_frontend_ops)); |
168 | state->frontend.demodulator_priv = state; | 163 | state->frontend.demodulator_priv = state; |
169 | return &state->frontend; | 164 | return &state->frontend; |
170 | |||
171 | error: | ||
172 | kfree(state); | ||
173 | return NULL; | ||
174 | } | 165 | } |
175 | 166 | ||
176 | static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = { | 167 | static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = { |