2015-08-14 09:43:15

by Adrian Remonda

[permalink] [raw]
Subject: [PATCHv6 0/5] Staging: most: several warnings fix reported by sparse

This patch series fix several warnings reported by the Sparse tool

v2: Fixed patch format and comments as noted by
Greg Kroah-Hartman and clear a few more warnings
v3: Fixed patch format as noted by Greg Kroah-Hartman
v4: Fixed patch format as noted by Greg Kroah-Hartman
v5: Because of using a non-updated tree previously two
patches did not apply
v6: Clear warnings and styling issues

Adrian Remonda (5):
Staging: most: mostcore/core.c. Fix "missing static keyword" warnings
Staging: most: mostcore/core.c. Fix "Using plain integer as NULL
pointer" warnings
Staging: most: hdm-usb/hdm_usb.c. Fix "missing static keyword"
warnings
Staging: most: hdm-dim2/dim2_hal.c. Fix "Using plain integer as NULL
pointer" warnings
Staging: most: aim-cdev/cdev.c. Fix "missing static keyword" warnings

drivers/staging/most/aim-cdev/cdev.c | 18 +++++++++---------
drivers/staging/most/hdm-dim2/dim2_hal.c | 2 +-
drivers/staging/most/hdm-usb/hdm_usb.c | 16 ++++++++--------
drivers/staging/most/mostcore/core.c | 17 +++++++++--------
4 files changed, 27 insertions(+), 26 deletions(-)

--
2.1.4


2015-08-14 09:43:29

by Adrian Remonda

[permalink] [raw]
Subject: [PATCHv6 1/5] Staging: most: mostcore/core.c. Fix "missing static keyword" warnings

This is a patch to the mostcore/core.c file. It makes
several local functions and structures static to prevent global
visibility.

Signed-off-by: Adrian Remonda <[email protected]>
---

v6: fixed warning "line over 80 characters" as pointed out by
Sudip Mukherjee

drivers/staging/most/mostcore/core.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c
index f4fea8cf5560..fa9c19b65a5c 100644
--- a/drivers/staging/most/mostcore/core.c
+++ b/drivers/staging/most/mostcore/core.c
@@ -178,7 +178,7 @@ static void most_free_mbo_coherent(struct mbo *mbo)
* flush_channel_fifos - clear the channel fifos
* @c: pointer to channel object
*/
-void flush_channel_fifos(struct most_c_obj *c)
+static void flush_channel_fifos(struct most_c_obj *c)
{
unsigned long flags, hf_flags;
struct mbo *mbo, *tmp;
@@ -888,7 +888,7 @@ static ssize_t show_add_link(struct most_aim_obj *aim_obj,
* Input: "mdev0:ch0@ep_81"
* Output: *a -> "mdev0", *b -> "ch0@ep_81", *c == NULL
*/
-int split_string(char *buf, char **a, char **b, char **c)
+static int split_string(char *buf, char **a, char **b, char **c)
{
*a = strsep(&buf, ":");
if (!*a)
@@ -1006,7 +1006,7 @@ static ssize_t store_add_link(struct most_aim_obj *aim_obj,
return len;
}

-struct most_aim_attribute most_aim_attr_add_link =
+static struct most_aim_attribute most_aim_attr_add_link =
__ATTR(add_link, S_IRUGO | S_IWUSR, show_add_link, store_add_link);

static ssize_t show_remove_link(struct most_aim_obj *aim_obj,
@@ -1057,7 +1057,7 @@ static ssize_t store_remove_link(struct most_aim_obj *aim_obj,
return len;
}

-struct most_aim_attribute most_aim_attr_remove_link =
+static struct most_aim_attribute most_aim_attr_remove_link =
__ATTR(remove_link, S_IRUGO | S_IWUSR, show_remove_link, store_remove_link);

static struct attribute *most_aim_def_attrs[] = {
@@ -1121,14 +1121,14 @@ static void destroy_most_aim_obj(struct most_aim_obj *p)
/**
* Instantiation of the MOST bus
*/
-struct bus_type most_bus = {
+static struct bus_type most_bus = {
.name = "most",
};

/**
* Instantiation of the core driver
*/
-struct device_driver mostcore = {
+static struct device_driver mostcore = {
.name = "mostcore",
.bus = &most_bus,
};
@@ -1255,7 +1255,8 @@ static void arm_mbo(struct mbo *mbo)
*
* Returns the number of allocated and enqueued MBOs.
*/
-int arm_mbo_chain(struct most_c_obj *c, int dir, void (*compl)(struct mbo *))
+static int arm_mbo_chain(struct most_c_obj *c, int dir,
+ void (*compl)(struct mbo *))
{
unsigned int i;
int retval;
--
2.1.4

2015-08-14 09:43:34

by Adrian Remonda

[permalink] [raw]
Subject: [PATCHv6 2/5] Staging: most: mostcore/core.c. Fix "Using plain integer as NULL pointer" warnings

This patch fixes the warning generated by sparse: "Using plain integer
as NULL pointer" by replacing the offending 0 with NULL.

Signed-off-by: Adrian Remonda <[email protected]>
---
v6: styling. Change the NULL test to comply with the Kernel coding style

drivers/staging/most/mostcore/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c
index fa9c19b65a5c..7bb16db42893 100644
--- a/drivers/staging/most/mostcore/core.c
+++ b/drivers/staging/most/mostcore/core.c
@@ -982,7 +982,7 @@ static ssize_t store_add_link(struct most_aim_obj *aim_obj,
if (ret)
return ret;

- if (mdev_devnod == 0 || *mdev_devnod == 0) {
+ if (!mdev_devnod || *mdev_devnod == 0) {
snprintf(devnod_buf, sizeof(devnod_buf), "%s-%s", mdev, mdev_ch);
mdev_devnod = devnod_buf;
}
--
2.1.4

2015-08-14 09:43:35

by Adrian Remonda

[permalink] [raw]
Subject: [PATCHv6 3/5] Staging: most: hdm-usb/hdm_usb.c. Fix "missing static keyword" warnings

This is a patch to the most/hdm-usb/hdm_usb.c file. It
makes several local functions and structures static to prevent global
visibility.

Signed-off-by: Adrian Remonda <[email protected]>
---

v6: fixed alignment with parameter list of a function.

drivers/staging/most/hdm-usb/hdm_usb.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/most/hdm-usb/hdm_usb.c b/drivers/staging/most/hdm-usb/hdm_usb.c
index 514ce3529b7a..305303f2f17c 100644
--- a/drivers/staging/most/hdm-usb/hdm_usb.c
+++ b/drivers/staging/most/hdm-usb/hdm_usb.c
@@ -290,7 +290,7 @@ static unsigned int get_stream_frame_size(struct most_channel_config *cfg)
*
* Returns 0 on success or error code otherwise.
*/
-int hdm_poison_channel(struct most_interface *iface, int channel)
+static int hdm_poison_channel(struct most_interface *iface, int channel)
{
struct most_dev *mdev;

@@ -328,7 +328,7 @@ int hdm_poison_channel(struct most_interface *iface, int channel)
* This inserts the INIC hardware specific padding bytes into a streaming
* channel's buffer
*/
-int hdm_add_padding(struct most_dev *mdev, int channel, struct mbo *mbo)
+static int hdm_add_padding(struct most_dev *mdev, int channel, struct mbo *mbo)
{
struct most_channel_config *conf = &mdev->conf[channel];
unsigned int j, num_frames, frame_size;
@@ -365,7 +365,7 @@ int hdm_add_padding(struct most_dev *mdev, int channel, struct mbo *mbo)
* This takes the INIC hardware specific padding bytes off a streaming
* channel's buffer.
*/
-int hdm_remove_padding(struct most_dev *mdev, int channel, struct mbo *mbo)
+static int hdm_remove_padding(struct most_dev *mdev, int channel, struct mbo *mbo)
{
unsigned int j, num_frames, frame_size;
struct most_channel_config *const conf = &mdev->conf[channel];
@@ -644,7 +644,7 @@ static void hdm_read_completion(struct urb *urb)
*
* Context: Could in _some_ cases be interrupt!
*/
-int hdm_enqueue(struct most_interface *iface, int channel, struct mbo *mbo)
+static int hdm_enqueue(struct most_interface *iface, int channel, struct mbo *mbo)
{
struct most_dev *mdev;
struct buf_anchor *anchor;
@@ -743,8 +743,8 @@ _error:
* @channel: channel ID
* @conf: structure that holds the configuration information
*/
-int hdm_configure_channel(struct most_interface *iface, int channel,
- struct most_channel_config *conf)
+static int hdm_configure_channel(struct most_interface *iface, int channel,
+ struct most_channel_config *conf)
{
unsigned int num_frames;
unsigned int frame_size;
@@ -824,7 +824,7 @@ exit:
* This triggers the USB vendor requests to read the hardware address and
* the current link status of the attached device.
*/
-int hdm_update_netinfo(struct most_dev *mdev)
+static int hdm_update_netinfo(struct most_dev *mdev)
{
struct device *dev = &mdev->usb_device->dev;
int i;
@@ -873,7 +873,7 @@ int hdm_update_netinfo(struct most_dev *mdev)
* polls for the NI state of the INIC every 2 seconds.
*
*/
-void hdm_request_netinfo(struct most_interface *iface, int channel)
+static void hdm_request_netinfo(struct most_interface *iface, int channel)
{
struct most_dev *mdev;

--
2.1.4

2015-08-14 09:43:37

by Adrian Remonda

[permalink] [raw]
Subject: [PATCHv6 4/5] Staging: most: hdm-dim2/dim2_hal.c. Fix "Using plain integer as NULL pointer" warnings

This patch fixes the warning generated by sparse: "Using plain integer
as NULL pointer" by replacing the offending 0 with NULL.

Signed-off-by: Adrian Remonda <[email protected]>
---
drivers/staging/most/hdm-dim2/dim2_hal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/most/hdm-dim2/dim2_hal.c b/drivers/staging/most/hdm-dim2/dim2_hal.c
index 01b748944ee4..a54cf2cedac3 100644
--- a/drivers/staging/most/hdm-dim2/dim2_hal.c
+++ b/drivers/staging/most/hdm-dim2/dim2_hal.c
@@ -889,7 +889,7 @@ struct dim_ch_state_t *DIM_GetChannelState(struct dim_channel *ch,
struct dim_ch_state_t *state_ptr)
{
if (!ch || !state_ptr)
- return 0;
+ return NULL;

state_ptr->ready = ch->state.level < 2;
state_ptr->done_buffers = ch->done_sw_buffers_number;
--
2.1.4

2015-08-14 09:43:38

by Adrian Remonda

[permalink] [raw]
Subject: [PATCHv6 5/5] Staging: most: aim-cdev/cdev.c. Fix "missing static keyword" warnings

This is a patch to the most/aim_cdev.c file. It makes several
local functions and structures static to prevent global visibility.

Signed-off-by: Adrian Remonda <[email protected]>
---
drivers/staging/most/aim-cdev/cdev.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/most/aim-cdev/cdev.c b/drivers/staging/most/aim-cdev/cdev.c
index 252a17cf153c..0a13d8d0fa39 100644
--- a/drivers/staging/most/aim-cdev/cdev.c
+++ b/drivers/staging/most/aim-cdev/cdev.c
@@ -49,7 +49,7 @@ static struct list_head channel_list;
static spinlock_t ch_list_lock;


-struct aim_channel *get_channel(struct most_interface *iface, int id)
+static struct aim_channel *get_channel(struct most_interface *iface, int id)
{
struct aim_channel *channel, *tmp;
unsigned long flags;
@@ -289,7 +289,7 @@ static const struct file_operations channel_fops = {
* This frees allocated memory and removes the cdev that represents this
* channel in user space.
*/
-int aim_disconnect_channel(struct most_interface *iface, int channel_id)
+static int aim_disconnect_channel(struct most_interface *iface, int channel_id)
{
struct aim_channel *channel;
unsigned long flags;
@@ -329,7 +329,7 @@ int aim_disconnect_channel(struct most_interface *iface, int channel_id)
* This searches for the channel linked to this MBO and stores it in the local
* fifo buffer.
*/
-int aim_rx_completion(struct mbo *mbo)
+static int aim_rx_completion(struct mbo *mbo)
{
struct aim_channel *channel;

@@ -356,7 +356,7 @@ int aim_rx_completion(struct mbo *mbo)
*
* This wakes sleeping processes in the wait-queue.
*/
-int aim_tx_completion(struct most_interface *iface, int channel_id)
+static int aim_tx_completion(struct most_interface *iface, int channel_id)
{
struct aim_channel *channel;

@@ -376,7 +376,7 @@ int aim_tx_completion(struct most_interface *iface, int channel_id)
return 0;
}

-struct most_aim cdev_aim;
+static struct most_aim cdev_aim;

/**
* aim_probe - probe function of the driver module
@@ -390,9 +390,9 @@ struct most_aim cdev_aim;
*
* Returns 0 on success or error code otherwise.
*/
-int aim_probe(struct most_interface *iface, int channel_id,
- struct most_channel_config *cfg,
- struct kobject *parent, char *name)
+static int aim_probe(struct most_interface *iface, int channel_id,
+ struct most_channel_config *cfg,
+ struct kobject *parent, char *name)
{
struct aim_channel *channel;
unsigned long cl_flags;
@@ -463,7 +463,7 @@ error_alloc_channel:
return retval;
}

-struct most_aim cdev_aim = {
+static struct most_aim cdev_aim = {
.name = "cdev",
.probe_channel = aim_probe,
.disconnect_channel = aim_disconnect_channel,
--
2.1.4

2015-08-14 10:02:45

by Frans Klaver

[permalink] [raw]
Subject: Re: [PATCHv6 2/5] Staging: most: mostcore/core.c. Fix "Using plain integer as NULL pointer" warnings

On Fri, Aug 14, 2015 at 11:42 AM, Adrian Remonda
<[email protected]> wrote:
> This patch fixes the warning generated by sparse: "Using plain integer
> as NULL pointer" by replacing the offending 0 with NULL.
>
> Signed-off-by: Adrian Remonda <[email protected]>
> ---
> v6: styling. Change the NULL test to comply with the Kernel coding style

Your commit message no longer fits the actual change...


> drivers/staging/most/mostcore/core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/most/mostcore/core.c b/drivers/staging/most/mostcore/core.c
> index fa9c19b65a5c..7bb16db42893 100644
> --- a/drivers/staging/most/mostcore/core.c
> +++ b/drivers/staging/most/mostcore/core.c
> @@ -982,7 +982,7 @@ static ssize_t store_add_link(struct most_aim_obj *aim_obj,
> if (ret)
> return ret;
>
> - if (mdev_devnod == 0 || *mdev_devnod == 0) {
> + if (!mdev_devnod || *mdev_devnod == 0) {
> snprintf(devnod_buf, sizeof(devnod_buf), "%s-%s", mdev, mdev_ch);
> mdev_devnod = devnod_buf;
> }
> --

Thanks,
Frans