Commit 14bef7a5 authored by Jean Delvare's avatar Jean Delvare Committed by Greg Kroah-Hartman

[PATCH] I2C: Remove NULL client checks in rtc8564 driver

Several functions in your rtc8564 driver verify the non-NULLity of the
i2c client that is passed to them. It doesn't seem to be necessary, as I
can't think of any case where these functions could possibly be called
with a NULL i2c client. As a matter of fact, I couldn't find any similar
driver doing such checks.

My attention was brought on this by Coverity's SWAT which correctly
noticed that three of these functions contain explicit or hidden
dereferences of the i2c client pointer *before* the NULL check. I guess
it wasn't a problem because the NULL case cannot happen (unless I miss
something), but this still is confusing code.

Thus I propose the following changes:
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 9962e883
......@@ -89,7 +89,7 @@ static int rtc8564_read(struct i2c_client *client, unsigned char adr,
_DBG(1, "client=%p, adr=%d, buf=%p, len=%d", client, adr, buf, len);
if (!buf || !client) {
if (!buf) {
ret = -EINVAL;
goto done;
}
......@@ -111,7 +111,7 @@ static int rtc8564_write(struct i2c_client *client, unsigned char adr,
struct i2c_msg wr;
int i;
if (!client || !data || len > 15) {
if (!data || len > 15) {
ret = -EINVAL;
goto done;
}
......@@ -220,7 +220,7 @@ static int rtc8564_get_datetime(struct i2c_client *client, struct rtc_tm *dt)
_DBG(1, "client=%p, dt=%p", client, dt);
if (!dt || !client)
if (!dt)
return -EINVAL;
memset(buf, 0, sizeof(buf));
......@@ -254,7 +254,7 @@ rtc8564_set_datetime(struct i2c_client *client, struct rtc_tm *dt, int datetoo)
_DBG(1, "client=%p, dt=%p", client, dt);
if (!dt || !client)
if (!dt)
return -EINVAL;
_DBGRTCTM(2, *dt);
......@@ -293,7 +293,7 @@ static int rtc8564_get_ctrl(struct i2c_client *client, unsigned int *ctrl)
{
struct rtc8564_data *data = i2c_get_clientdata(client);
if (!ctrl || !client)
if (!ctrl)
return -1;
*ctrl = data->ctrl;
......@@ -305,7 +305,7 @@ static int rtc8564_set_ctrl(struct i2c_client *client, unsigned int *ctrl)
struct rtc8564_data *data = i2c_get_clientdata(client);
unsigned char buf[2];
if (!ctrl || !client)
if (!ctrl)
return -1;
buf[0] = *ctrl & 0xff;
......@@ -318,7 +318,7 @@ static int rtc8564_set_ctrl(struct i2c_client *client, unsigned int *ctrl)
static int rtc8564_read_mem(struct i2c_client *client, struct mem *mem)
{
if (!mem || !client)
if (!mem)
return -EINVAL;
return rtc8564_read(client, mem->loc, mem->data, mem->nr);
......@@ -327,7 +327,7 @@ static int rtc8564_read_mem(struct i2c_client *client, struct mem *mem)
static int rtc8564_write_mem(struct i2c_client *client, struct mem *mem)
{
if (!mem || !client)
if (!mem)
return -EINVAL;
return rtc8564_write(client, mem->loc, mem->data, mem->nr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment