* [PATCH 01/10] staging: irda: Improve a size determination in 20 functions
2017-10-12 10:38 [PATCH 00/10] staging/irda/net: Adjustments for several function implementations SF Markus Elfring
@ 2017-10-12 10:39 ` SF Markus Elfring
2017-10-12 10:40 ` [PATCH 02/10] staging: irda: Delete ten error messages for a failed memory allocation SF Markus Elfring
` (8 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-12 10:39 UTC (permalink / raw)
To: devel, netdev, Al Viro, Corentin Labbe, David Howells,
David S. Miller, Georgiana Chelu, Greg Kroah-Hartman,
Johannes Berg, Julia Lawall, Samuel Ortiz, Srishti Sharma,
Stephen Hemminger, Yuan Linyu
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 10 Oct 2017 19:35:56 +0200
* Replace the specification of data types by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
* The script "checkpatch.pl" pointed information out like the following.
ERROR: do not use assignment in if condition
Thus fix the affected source code place.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/irda/net/ircomm/ircomm_core.c | 2 +-
drivers/staging/irda/net/ircomm/ircomm_tty.c | 2 +-
drivers/staging/irda/net/irias_object.c | 16 ++++++++--------
drivers/staging/irda/net/irlap.c | 2 +-
drivers/staging/irda/net/irlap_frame.c | 7 ++++---
drivers/staging/irda/net/irlmp.c | 8 ++++----
drivers/staging/irda/net/irttp.c | 4 ++--
7 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/drivers/staging/irda/net/ircomm/ircomm_core.c b/drivers/staging/irda/net/ircomm/ircomm_core.c
index 3af219545f6d..6c02fbf380bd 100644
--- a/drivers/staging/irda/net/ircomm/ircomm_core.c
+++ b/drivers/staging/irda/net/ircomm/ircomm_core.c
@@ -114,7 +114,7 @@ struct ircomm_cb *ircomm_open(notify_t *notify, __u8 service_type, int line)
IRDA_ASSERT(ircomm != NULL, return NULL;);
- self = kzalloc(sizeof(struct ircomm_cb), GFP_KERNEL);
+ self = kzalloc(sizeof(*self), GFP_KERNEL);
if (self = NULL)
return NULL;
diff --git a/drivers/staging/irda/net/ircomm/ircomm_tty.c b/drivers/staging/irda/net/ircomm/ircomm_tty.c
index ec157c3419b5..d1beec413fa3 100644
--- a/drivers/staging/irda/net/ircomm/ircomm_tty.c
+++ b/drivers/staging/irda/net/ircomm/ircomm_tty.c
@@ -380,7 +380,7 @@ static int ircomm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
self = hashbin_lock_find(ircomm_tty, line, NULL);
if (!self) {
/* No, so make new instance */
- self = kzalloc(sizeof(struct ircomm_tty_cb), GFP_KERNEL);
+ self = kzalloc(sizeof(*self), GFP_KERNEL);
if (self = NULL)
return -ENOMEM;
diff --git a/drivers/staging/irda/net/irias_object.c b/drivers/staging/irda/net/irias_object.c
index 53b86d0e1630..1064fac2fd36 100644
--- a/drivers/staging/irda/net/irias_object.c
+++ b/drivers/staging/irda/net/irias_object.c
@@ -48,7 +48,7 @@ struct ias_object *irias_new_object( char *name, int id)
{
struct ias_object *obj;
- obj = kzalloc(sizeof(struct ias_object), GFP_ATOMIC);
+ obj = kzalloc(sizeof(*obj), GFP_ATOMIC);
if (obj = NULL) {
net_warn_ratelimited("%s(), Unable to allocate object!\n",
__func__);
@@ -318,7 +318,7 @@ void irias_add_integer_attrib(struct ias_object *obj, char *name, int value,
IRDA_ASSERT(obj->magic = IAS_OBJECT_MAGIC, return;);
IRDA_ASSERT(name != NULL, return;);
- attrib = kzalloc(sizeof(struct ias_attrib), GFP_ATOMIC);
+ attrib = kzalloc(sizeof(*attrib), GFP_ATOMIC);
if (attrib = NULL) {
net_warn_ratelimited("%s: Unable to allocate attribute!\n",
__func__);
@@ -362,7 +362,7 @@ void irias_add_octseq_attrib(struct ias_object *obj, char *name, __u8 *octets,
IRDA_ASSERT(name != NULL, return;);
IRDA_ASSERT(octets != NULL, return;);
- attrib = kzalloc(sizeof(struct ias_attrib), GFP_ATOMIC);
+ attrib = kzalloc(sizeof(*attrib), GFP_ATOMIC);
if (attrib = NULL) {
net_warn_ratelimited("%s: Unable to allocate attribute!\n",
__func__);
@@ -404,7 +404,7 @@ void irias_add_string_attrib(struct ias_object *obj, char *name, char *value,
IRDA_ASSERT(name != NULL, return;);
IRDA_ASSERT(value != NULL, return;);
- attrib = kzalloc(sizeof( struct ias_attrib), GFP_ATOMIC);
+ attrib = kzalloc(sizeof(*attrib), GFP_ATOMIC);
if (attrib = NULL) {
net_warn_ratelimited("%s: Unable to allocate attribute!\n",
__func__);
@@ -439,7 +439,7 @@ struct ias_value *irias_new_integer_value(int integer)
{
struct ias_value *value;
- value = kzalloc(sizeof(struct ias_value), GFP_ATOMIC);
+ value = kzalloc(sizeof(*value), GFP_ATOMIC);
if (value = NULL)
return NULL;
@@ -462,7 +462,7 @@ struct ias_value *irias_new_string_value(char *string)
{
struct ias_value *value;
- value = kzalloc(sizeof(struct ias_value), GFP_ATOMIC);
+ value = kzalloc(sizeof(*value), GFP_ATOMIC);
if (value = NULL)
return NULL;
@@ -491,7 +491,7 @@ struct ias_value *irias_new_octseq_value(__u8 *octseq , int len)
{
struct ias_value *value;
- value = kzalloc(sizeof(struct ias_value), GFP_ATOMIC);
+ value = kzalloc(sizeof(*value), GFP_ATOMIC);
if (value = NULL)
return NULL;
@@ -514,7 +514,7 @@ struct ias_value *irias_new_missing_value(void)
{
struct ias_value *value;
- value = kzalloc(sizeof(struct ias_value), GFP_ATOMIC);
+ value = kzalloc(sizeof(*value), GFP_ATOMIC);
if (value = NULL)
return NULL;
diff --git a/drivers/staging/irda/net/irlap.c b/drivers/staging/irda/net/irlap.c
index 1cde711bcab5..5dea721f44ac 100644
--- a/drivers/staging/irda/net/irlap.c
+++ b/drivers/staging/irda/net/irlap.c
@@ -110,7 +110,7 @@ struct irlap_cb *irlap_open(struct net_device *dev, struct qos_info *qos,
struct irlap_cb *self;
/* Initialize the irlap structure. */
- self = kzalloc(sizeof(struct irlap_cb), GFP_KERNEL);
+ self = kzalloc(sizeof(*self), GFP_KERNEL);
if (self = NULL)
return NULL;
diff --git a/drivers/staging/irda/net/irlap_frame.c b/drivers/staging/irda/net/irlap_frame.c
index debda3de4726..21891ef7ee33 100644
--- a/drivers/staging/irda/net/irlap_frame.c
+++ b/drivers/staging/irda/net/irlap_frame.c
@@ -432,7 +432,8 @@ static void irlap_recv_discovery_xid_rsp(struct irlap_cb *self,
return;
}
- if ((discovery = kzalloc(sizeof(discovery_t), GFP_ATOMIC)) = NULL) {
+ discovery = kzalloc(sizeof(*discovery), GFP_ATOMIC);
+ if (!discovery) {
net_warn_ratelimited("%s: kmalloc failed!\n", __func__);
return;
}
@@ -539,7 +540,7 @@ static void irlap_recv_discovery_xid_cmd(struct irlap_cb *self,
/*
* We now have some discovery info to deliver!
*/
- discovery = kzalloc(sizeof(discovery_t), GFP_ATOMIC);
+ discovery = kzalloc(sizeof(*discovery), GFP_ATOMIC);
if (!discovery)
return;
@@ -1201,7 +1202,7 @@ void irlap_send_test_frame(struct irlap_cb *self, __u8 caddr, __u32 daddr,
/* Broadcast frames must include saddr and daddr fields */
if (caddr = CBROADCAST) {
- frame = skb_put(tx_skb, sizeof(struct test_frame));
+ frame = skb_put(tx_skb, sizeof(*frame));
/* Insert the swapped addresses */
frame->saddr = cpu_to_le32(self->saddr);
diff --git a/drivers/staging/irda/net/irlmp.c b/drivers/staging/irda/net/irlmp.c
index 43964594aa12..38772a3b9df8 100644
--- a/drivers/staging/irda/net/irlmp.c
+++ b/drivers/staging/irda/net/irlmp.c
@@ -168,7 +168,7 @@ struct lsap_cb *irlmp_open_lsap(__u8 slsap_sel, notify_t *notify, __u8 pid)
return NULL;
/* Allocate new instance of a LSAP connection */
- self = kzalloc(sizeof(struct lsap_cb), GFP_ATOMIC);
+ self = kzalloc(sizeof(*self), GFP_ATOMIC);
if (self = NULL)
return NULL;
@@ -290,7 +290,7 @@ void irlmp_register_link(struct irlap_cb *irlap, __u32 saddr, notify_t *notify)
/*
* Allocate new instance of a LSAP connection
*/
- lap = kzalloc(sizeof(struct lap_cb), GFP_KERNEL);
+ lap = kzalloc(sizeof(*lap), GFP_KERNEL);
if (lap = NULL)
return;
@@ -1466,7 +1466,7 @@ void *irlmp_register_service(__u16 hints)
pr_debug("%s(), hints = %04x\n", __func__, hints);
/* Make a new registration */
- service = kmalloc(sizeof(irlmp_service_t), GFP_ATOMIC);
+ service = kmalloc(sizeof(*service), GFP_ATOMIC);
if (!service)
return NULL;
@@ -1538,7 +1538,7 @@ void *irlmp_register_client(__u16 hint_mask, DISCOVERY_CALLBACK1 disco_clb,
IRDA_ASSERT(irlmp != NULL, return NULL;);
/* Make a new registration */
- client = kmalloc(sizeof(irlmp_client_t), GFP_ATOMIC);
+ client = kmalloc(sizeof(*client), GFP_ATOMIC);
if (!client)
return NULL;
diff --git a/drivers/staging/irda/net/irttp.c b/drivers/staging/irda/net/irttp.c
index b6ab41d5b3a3..958bfbe38bfb 100644
--- a/drivers/staging/irda/net/irttp.c
+++ b/drivers/staging/irda/net/irttp.c
@@ -403,7 +403,7 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify)
return NULL;
}
- self = kzalloc(sizeof(struct tsap_cb), GFP_ATOMIC);
+ self = kzalloc(sizeof(*self), GFP_ATOMIC);
if (self = NULL)
return NULL;
@@ -1441,7 +1441,7 @@ struct tsap_cb *irttp_dup(struct tsap_cb *orig, void *instance)
}
/* Allocate a new instance */
- new = kmemdup(orig, sizeof(struct tsap_cb), GFP_ATOMIC);
+ new = kmemdup(orig, sizeof(*new), GFP_ATOMIC);
if (!new) {
pr_debug("%s(), unable to kmalloc\n", __func__);
spin_unlock_irqrestore(&irttp->tsaps->hb_spinlock, flags);
--
2.14.2
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 02/10] staging: irda: Delete ten error messages for a failed memory allocation
2017-10-12 10:38 [PATCH 00/10] staging/irda/net: Adjustments for several function implementations SF Markus Elfring
2017-10-12 10:39 ` [PATCH 01/10] staging: irda: Improve a size determination in 20 functions SF Markus Elfring
@ 2017-10-12 10:40 ` SF Markus Elfring
2017-10-12 10:43 ` [PATCH 04/10] staging/irda/net: Delete an unnecessary variable initialisation in irlap_recv_discover SF Markus Elfring
` (7 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-12 10:40 UTC (permalink / raw)
To: devel, netdev, Al Viro, Corentin Labbe, David Howells,
David S. Miller, Georgiana Chelu, Greg Kroah-Hartman,
Johannes Berg, Julia Lawall, Samuel Ortiz, Srishti Sharma,
Stephen Hemminger, Yuan Linyu
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 10 Oct 2017 21:10:43 +0200
Omit extra messages for a memory allocation failure in these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/irda/net/irias_object.c | 24 ++++--------------------
drivers/staging/irda/net/irlap_frame.c | 4 +---
drivers/staging/irda/net/irlmp.c | 1 -
drivers/staging/irda/net/irttp.c | 1 -
4 files changed, 5 insertions(+), 25 deletions(-)
diff --git a/drivers/staging/irda/net/irias_object.c b/drivers/staging/irda/net/irias_object.c
index 1064fac2fd36..4db986b9d756 100644
--- a/drivers/staging/irda/net/irias_object.c
+++ b/drivers/staging/irda/net/irias_object.c
@@ -49,17 +49,12 @@ struct ias_object *irias_new_object( char *name, int id)
struct ias_object *obj;
obj = kzalloc(sizeof(*obj), GFP_ATOMIC);
- if (obj = NULL) {
- net_warn_ratelimited("%s(), Unable to allocate object!\n",
- __func__);
+ if (!obj)
return NULL;
- }
obj->magic = IAS_OBJECT_MAGIC;
obj->name = kstrndup(name, IAS_MAX_CLASSNAME, GFP_ATOMIC);
if (!obj->name) {
- net_warn_ratelimited("%s(), Unable to allocate name!\n",
- __func__);
kfree(obj);
return NULL;
}
@@ -319,11 +314,8 @@ void irias_add_integer_attrib(struct ias_object *obj, char *name, int value,
IRDA_ASSERT(name != NULL, return;);
attrib = kzalloc(sizeof(*attrib), GFP_ATOMIC);
- if (attrib = NULL) {
- net_warn_ratelimited("%s: Unable to allocate attribute!\n",
- __func__);
+ if (!attrib)
return;
- }
attrib->magic = IAS_ATTRIB_MAGIC;
attrib->name = kstrndup(name, IAS_MAX_ATTRIBNAME, GFP_ATOMIC);
@@ -363,11 +355,8 @@ void irias_add_octseq_attrib(struct ias_object *obj, char *name, __u8 *octets,
IRDA_ASSERT(octets != NULL, return;);
attrib = kzalloc(sizeof(*attrib), GFP_ATOMIC);
- if (attrib = NULL) {
- net_warn_ratelimited("%s: Unable to allocate attribute!\n",
- __func__);
+ if (!attrib)
return;
- }
attrib->magic = IAS_ATTRIB_MAGIC;
attrib->name = kstrndup(name, IAS_MAX_ATTRIBNAME, GFP_ATOMIC);
@@ -405,11 +394,8 @@ void irias_add_string_attrib(struct ias_object *obj, char *name, char *value,
IRDA_ASSERT(value != NULL, return;);
attrib = kzalloc(sizeof(*attrib), GFP_ATOMIC);
- if (attrib = NULL) {
- net_warn_ratelimited("%s: Unable to allocate attribute!\n",
- __func__);
+ if (!attrib)
return;
- }
attrib->magic = IAS_ATTRIB_MAGIC;
attrib->name = kstrndup(name, IAS_MAX_ATTRIBNAME, GFP_ATOMIC);
@@ -470,7 +456,6 @@ struct ias_value *irias_new_string_value(char *string)
value->charset = CS_ASCII;
value->t.string = kstrndup(string, IAS_MAX_STRING, GFP_ATOMIC);
if (!value->t.string) {
- net_warn_ratelimited("%s: Unable to kmalloc!\n", __func__);
kfree(value);
return NULL;
}
@@ -503,7 +488,6 @@ struct ias_value *irias_new_octseq_value(__u8 *octseq , int len)
value->t.oct_seq = kmemdup(octseq, len, GFP_ATOMIC);
if (value->t.oct_seq = NULL){
- net_warn_ratelimited("%s: Unable to kmalloc!\n", __func__);
kfree(value);
return NULL;
}
diff --git a/drivers/staging/irda/net/irlap_frame.c b/drivers/staging/irda/net/irlap_frame.c
index 21891ef7ee33..d4d88a5d2976 100644
--- a/drivers/staging/irda/net/irlap_frame.c
+++ b/drivers/staging/irda/net/irlap_frame.c
@@ -433,10 +433,8 @@ static void irlap_recv_discovery_xid_rsp(struct irlap_cb *self,
}
discovery = kzalloc(sizeof(*discovery), GFP_ATOMIC);
- if (!discovery) {
- net_warn_ratelimited("%s: kmalloc failed!\n", __func__);
+ if (!discovery)
return;
- }
discovery->data.daddr = info->daddr;
discovery->data.saddr = self->saddr;
diff --git a/drivers/staging/irda/net/irlmp.c b/drivers/staging/irda/net/irlmp.c
index 38772a3b9df8..f075735e4b9b 100644
--- a/drivers/staging/irda/net/irlmp.c
+++ b/drivers/staging/irda/net/irlmp.c
@@ -641,7 +641,6 @@ struct lsap_cb *irlmp_dup(struct lsap_cb *orig, void *instance)
/* Allocate a new instance */
new = kmemdup(orig, sizeof(*new), GFP_ATOMIC);
if (!new) {
- pr_debug("%s(), unable to kmalloc\n", __func__);
spin_unlock_irqrestore(&irlmp->unconnected_lsaps->hb_spinlock,
flags);
return NULL;
diff --git a/drivers/staging/irda/net/irttp.c b/drivers/staging/irda/net/irttp.c
index 958bfbe38bfb..bcab5a60cd47 100644
--- a/drivers/staging/irda/net/irttp.c
+++ b/drivers/staging/irda/net/irttp.c
@@ -1443,7 +1443,6 @@ struct tsap_cb *irttp_dup(struct tsap_cb *orig, void *instance)
/* Allocate a new instance */
new = kmemdup(orig, sizeof(*new), GFP_ATOMIC);
if (!new) {
- pr_debug("%s(), unable to kmalloc\n", __func__);
spin_unlock_irqrestore(&irttp->tsaps->hb_spinlock, flags);
return NULL;
}
--
2.14.2
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 04/10] staging/irda/net: Delete an unnecessary variable initialisation in irlap_recv_discover
2017-10-12 10:38 [PATCH 00/10] staging/irda/net: Adjustments for several function implementations SF Markus Elfring
2017-10-12 10:39 ` [PATCH 01/10] staging: irda: Improve a size determination in 20 functions SF Markus Elfring
2017-10-12 10:40 ` [PATCH 02/10] staging: irda: Delete ten error messages for a failed memory allocation SF Markus Elfring
@ 2017-10-12 10:43 ` SF Markus Elfring
2017-10-12 10:45 ` [PATCH 05/10] " SF Markus Elfring
` (6 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-12 10:43 UTC (permalink / raw)
To: devel, netdev, Al Viro, Corentin Labbe, David Howells,
David S. Miller, Georgiana Chelu, Greg Kroah-Hartman,
Johannes Berg, Julia Lawall, Samuel Ortiz, Srishti Sharma,
Stephen Hemminger, Yuan Linyu
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 11 Oct 2017 22:18:34 +0200
The local variable "discovery" will only be used in a single if branch
of this function. Thus omit the explicit initialisation at the beginning.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/irda/net/irlap_frame.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/irda/net/irlap_frame.c b/drivers/staging/irda/net/irlap_frame.c
index 94972db87951..33259ed5f3cd 100644
--- a/drivers/staging/irda/net/irlap_frame.c
+++ b/drivers/staging/irda/net/irlap_frame.c
@@ -481,7 +481,7 @@ static void irlap_recv_discovery_xid_cmd(struct irlap_cb *self,
struct irlap_info *info)
{
struct xid_frame *xid;
- discovery_t *discovery = NULL;
+ discovery_t *discovery;
__u8 *discovery_info;
char *text;
--
2.14.2
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 05/10] staging/irda/net: Delete an unnecessary variable initialisation in irlap_recv_discover
2017-10-12 10:38 [PATCH 00/10] staging/irda/net: Adjustments for several function implementations SF Markus Elfring
` (2 preceding siblings ...)
2017-10-12 10:43 ` [PATCH 04/10] staging/irda/net: Delete an unnecessary variable initialisation in irlap_recv_discover SF Markus Elfring
@ 2017-10-12 10:45 ` SF Markus Elfring
2017-10-12 10:46 ` [PATCH 06/10] staging/irda/net: Delete an unnecessary variable initialisation in two functions SF Markus Elfring
` (5 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-12 10:45 UTC (permalink / raw)
To: devel, netdev, Al Viro, Corentin Labbe, David Howells,
David S. Miller, Georgiana Chelu, Greg Kroah-Hartman,
Johannes Berg, Julia Lawall, Samuel Ortiz, Srishti Sharma,
Stephen Hemminger, Yuan Linyu
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 11 Oct 2017 22:20:22 +0200
The variable "discovery" will eventually be set to an appropriate pointer
a bit later. Thus omit the explicit initialisation at the beginning.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/irda/net/irlap_frame.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/irda/net/irlap_frame.c b/drivers/staging/irda/net/irlap_frame.c
index 33259ed5f3cd..5b8be5b9812e 100644
--- a/drivers/staging/irda/net/irlap_frame.c
+++ b/drivers/staging/irda/net/irlap_frame.c
@@ -408,7 +408,7 @@ static void irlap_recv_discovery_xid_rsp(struct irlap_cb *self,
struct irlap_info *info)
{
struct xid_frame *xid;
- discovery_t *discovery = NULL;
+ discovery_t *discovery;
__u8 *discovery_info;
char *text;
--
2.14.2
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 06/10] staging/irda/net: Delete an unnecessary variable initialisation in two functions
2017-10-12 10:38 [PATCH 00/10] staging/irda/net: Adjustments for several function implementations SF Markus Elfring
` (3 preceding siblings ...)
2017-10-12 10:45 ` [PATCH 05/10] " SF Markus Elfring
@ 2017-10-12 10:46 ` SF Markus Elfring
2017-10-12 10:47 ` [PATCH 07/10] staging/irda/net: Delete an unnecessary variable initialisation in four functions SF Markus Elfring
` (4 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-12 10:46 UTC (permalink / raw)
To: devel, netdev, Al Viro, Corentin Labbe, David Howells,
David S. Miller, Georgiana Chelu, Greg Kroah-Hartman,
Johannes Berg, Julia Lawall, Samuel Ortiz, Srishti Sharma,
Stephen Hemminger, Yuan Linyu
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 11 Oct 2017 22:22:13 +0200
The local variable "tx_skb" will only be used in a single if branch
of these functions. Thus omit the explicit initialisation at the beginning.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/irda/net/irlap_frame.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/irda/net/irlap_frame.c b/drivers/staging/irda/net/irlap_frame.c
index 5b8be5b9812e..25ceb06efd58 100644
--- a/drivers/staging/irda/net/irlap_frame.c
+++ b/drivers/staging/irda/net/irlap_frame.c
@@ -862,7 +862,7 @@ void irlap_send_data_primary_poll(struct irlap_cb *self, struct sk_buff *skb)
void irlap_send_data_secondary_final(struct irlap_cb *self,
struct sk_buff *skb)
{
- struct sk_buff *tx_skb = NULL;
+ struct sk_buff *tx_skb;
IRDA_ASSERT(self, return;);
IRDA_ASSERT(self->magic = LAP_MAGIC, return;);
@@ -922,7 +922,7 @@ void irlap_send_data_secondary_final(struct irlap_cb *self,
*/
void irlap_send_data_secondary(struct irlap_cb *self, struct sk_buff *skb)
{
- struct sk_buff *tx_skb = NULL;
+ struct sk_buff *tx_skb;
/* Is this reliable or unreliable data? */
if (skb->data[1] = I_FRAME) {
--
2.14.2
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 07/10] staging/irda/net: Delete an unnecessary variable initialisation in four functions
2017-10-12 10:38 [PATCH 00/10] staging/irda/net: Adjustments for several function implementations SF Markus Elfring
` (4 preceding siblings ...)
2017-10-12 10:46 ` [PATCH 06/10] staging/irda/net: Delete an unnecessary variable initialisation in two functions SF Markus Elfring
@ 2017-10-12 10:47 ` SF Markus Elfring
2017-10-12 10:48 ` [PATCH 08/10] staging/irda/net: Use common error handling code in irias_new_object() SF Markus Elfring
` (3 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-12 10:47 UTC (permalink / raw)
To: devel, netdev, Al Viro, Corentin Labbe, David Howells,
David S. Miller, Georgiana Chelu, Greg Kroah-Hartman,
Johannes Berg, Julia Lawall, Samuel Ortiz, Srishti Sharma,
Stephen Hemminger, Yuan Linyu
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 11 Oct 2017 22:26:00 +0200
The variable "tx_skb" will eventually be set to an appropriate pointer
a bit later. Thus omit the explicit initialisation at the beginning.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/irda/net/irlap_frame.c | 6 +++---
drivers/staging/irda/net/irttp.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/irda/net/irlap_frame.c b/drivers/staging/irda/net/irlap_frame.c
index 25ceb06efd58..16fe7f53fdb7 100644
--- a/drivers/staging/irda/net/irlap_frame.c
+++ b/drivers/staging/irda/net/irlap_frame.c
@@ -258,7 +258,7 @@ void irlap_send_ua_response_frame(struct irlap_cb *self, struct qos_info *qos)
*/
void irlap_send_dm_frame( struct irlap_cb *self)
{
- struct sk_buff *tx_skb = NULL;
+ struct sk_buff *tx_skb;
struct dm_frame *frame;
IRDA_ASSERT(self, return;);
@@ -288,7 +288,7 @@ void irlap_send_dm_frame( struct irlap_cb *self)
*/
void irlap_send_disc_frame(struct irlap_cb *self)
{
- struct sk_buff *tx_skb = NULL;
+ struct sk_buff *tx_skb;
struct disc_frame *frame;
IRDA_ASSERT(self, return;);
@@ -315,7 +315,7 @@ void irlap_send_disc_frame(struct irlap_cb *self)
void irlap_send_discovery_xid_frame(struct irlap_cb *self, int S, __u8 s,
__u8 command, discovery_t *discovery)
{
- struct sk_buff *tx_skb = NULL;
+ struct sk_buff *tx_skb;
struct xid_frame *frame;
__u32 bcast = BROADCAST;
__u8 *info;
diff --git a/drivers/staging/irda/net/irttp.c b/drivers/staging/irda/net/irttp.c
index 2adba87aeb68..bc612227cdc3 100644
--- a/drivers/staging/irda/net/irttp.c
+++ b/drivers/staging/irda/net/irttp.c
@@ -811,7 +811,7 @@ static void irttp_run_tx_queue(struct tsap_cb *self)
*/
static inline void irttp_give_credit(struct tsap_cb *self)
{
- struct sk_buff *tx_skb = NULL;
+ struct sk_buff *tx_skb;
unsigned long flags;
int n;
--
2.14.2
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 08/10] staging/irda/net: Use common error handling code in irias_new_object()
2017-10-12 10:38 [PATCH 00/10] staging/irda/net: Adjustments for several function implementations SF Markus Elfring
` (5 preceding siblings ...)
2017-10-12 10:47 ` [PATCH 07/10] staging/irda/net: Delete an unnecessary variable initialisation in four functions SF Markus Elfring
@ 2017-10-12 10:48 ` SF Markus Elfring
2017-10-12 10:49 ` [PATCH 09/10] staging/irda/net: Combine some seq_printf() calls in two functions SF Markus Elfring
` (2 subsequent siblings)
9 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-12 10:48 UTC (permalink / raw)
To: devel, netdev, Al Viro, Corentin Labbe, David Howells,
David S. Miller, Georgiana Chelu, Greg Kroah-Hartman,
Johannes Berg, Julia Lawall, Samuel Ortiz, Srishti Sharma,
Stephen Hemminger, Yuan Linyu
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 12 Oct 2017 08:52:53 +0200
Add a jump target so that a bit of exception handling can be better
reused at the end of this function.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/irda/net/irias_object.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/irda/net/irias_object.c b/drivers/staging/irda/net/irias_object.c
index 4c2c65e28836..0c89800d597d 100644
--- a/drivers/staging/irda/net/irias_object.c
+++ b/drivers/staging/irda/net/irias_object.c
@@ -54,10 +54,9 @@ struct ias_object *irias_new_object( char *name, int id)
obj->magic = IAS_OBJECT_MAGIC;
obj->name = kstrndup(name, IAS_MAX_CLASSNAME, GFP_ATOMIC);
- if (!obj->name) {
- kfree(obj);
- return NULL;
- }
+ if (!obj->name)
+ goto free_object;
+
obj->id = id;
/* Locking notes : the attrib spinlock has lower precendence
@@ -68,11 +67,14 @@ struct ias_object *irias_new_object( char *name, int id)
net_warn_ratelimited("%s(), Unable to allocate attribs!\n",
__func__);
kfree(obj->name);
- kfree(obj);
- return NULL;
+ goto free_object;
}
return obj;
+
+free_object:
+ kfree(obj);
+ return NULL;
}
EXPORT_SYMBOL(irias_new_object);
--
2.14.2
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 09/10] staging/irda/net: Combine some seq_printf() calls in two functions
2017-10-12 10:38 [PATCH 00/10] staging/irda/net: Adjustments for several function implementations SF Markus Elfring
` (6 preceding siblings ...)
2017-10-12 10:48 ` [PATCH 08/10] staging/irda/net: Use common error handling code in irias_new_object() SF Markus Elfring
@ 2017-10-12 10:49 ` SF Markus Elfring
2017-10-12 10:50 ` [PATCH 10/10] staging/irda/net: Use seq_puts() in four functions SF Markus Elfring
2017-10-12 11:17 ` [PATCH 00/10] staging/irda/net: Adjustments for several function implementations Bjørn Mork
9 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-12 10:49 UTC (permalink / raw)
To: devel, netdev, Al Viro, Corentin Labbe, David Howells,
David S. Miller, Georgiana Chelu, Greg Kroah-Hartman,
Johannes Berg, Julia Lawall, Samuel Ortiz, Srishti Sharma,
Stephen Hemminger, Yuan Linyu
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 12 Oct 2017 08:58:38 +0200
Some data were printed into a sequence by separate function calls.
Print the same data by a single function call at each place instead.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/irda/net/irlap.c | 9 ++++-----
drivers/staging/irda/net/irlmp.c | 6 ++----
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/irda/net/irlap.c b/drivers/staging/irda/net/irlap.c
index 715cedab2f41..345c4eb55a59 100644
--- a/drivers/staging/irda/net/irlap.c
+++ b/drivers/staging/irda/net/irlap.c
@@ -1141,9 +1141,9 @@ static int irlap_seq_show(struct seq_file *seq, void *v)
seq_printf(seq, "vr: %d ", self->vr);
seq_printf(seq, "va: %d\n", self->va);
- seq_printf(seq, " qos\tbps\tmaxtt\tdsize\twinsize\taddbofs\tmintt\tldisc\tcomp\n");
-
- seq_printf(seq, " tx\t%d\t",
+ seq_printf(seq,
+ " qos\tbps\tmaxtt\tdsize\twinsize\taddbofs\tmintt\tldisc\tcomp\n"
+ " tx\t%d\t",
self->qos_tx.baud_rate.value);
seq_printf(seq, "%d\t",
self->qos_tx.max_turn_time.value);
@@ -1157,9 +1157,8 @@ static int irlap_seq_show(struct seq_file *seq, void *v)
self->qos_tx.min_turn_time.value);
seq_printf(seq, "%d\t",
self->qos_tx.link_disc_time.value);
- seq_printf(seq, "\n");
- seq_printf(seq, " rx\t%d\t",
+ seq_printf(seq, "\n rx\t%d\t",
self->qos_rx.baud_rate.value);
seq_printf(seq, "%d\t",
self->qos_rx.max_turn_time.value);
diff --git a/drivers/staging/irda/net/irlmp.c b/drivers/staging/irda/net/irlmp.c
index 318660fbc094..6a09cf621bd4 100644
--- a/drivers/staging/irda/net/irlmp.c
+++ b/drivers/staging/irda/net/irlmp.c
@@ -1920,8 +1920,7 @@ static int irlmp_seq_show(struct seq_file *seq, void *v)
seq_printf(seq,
"slsap_sel: %#02x, dlsap_sel: %#02x, ",
self->slsap_sel, self->dlsap_sel);
- seq_printf(seq, "(%s)", self->notify.name);
- seq_printf(seq, "\n");
+ seq_printf(seq, "(%s)\n", self->notify.name);
} else if (iter->hashbin = irlmp->links) {
struct lap_cb *lap = v;
@@ -1930,9 +1929,8 @@ static int irlmp_seq_show(struct seq_file *seq, void *v)
seq_printf(seq, "saddr: %#08x, daddr: %#08x, ",
lap->saddr, lap->daddr);
- seq_printf(seq, "num lsaps: %d",
+ seq_printf(seq, "num lsaps: %d\n",
HASHBIN_GET_SIZE(lap->lsaps));
- seq_printf(seq, "\n");
/* Careful for priority inversions here !
* All other uses of attrib spinlock are independent of
--
2.14.2
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 10/10] staging/irda/net: Use seq_puts() in four functions
2017-10-12 10:38 [PATCH 00/10] staging/irda/net: Adjustments for several function implementations SF Markus Elfring
` (7 preceding siblings ...)
2017-10-12 10:49 ` [PATCH 09/10] staging/irda/net: Combine some seq_printf() calls in two functions SF Markus Elfring
@ 2017-10-12 10:50 ` SF Markus Elfring
2017-10-12 11:17 ` [PATCH 00/10] staging/irda/net: Adjustments for several function implementations Bjørn Mork
9 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-12 10:50 UTC (permalink / raw)
To: devel, netdev, Al Viro, Corentin Labbe, David Howells,
David S. Miller, Georgiana Chelu, Greg Kroah-Hartman,
Johannes Berg, Julia Lawall, Samuel Ortiz, Srishti Sharma,
Stephen Hemminger, Yuan Linyu
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 12 Oct 2017 11:08:36 +0200
Strings which did not contain a data format specification should be put
into a sequence. Thus use the corresponding function "seq_puts".
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/irda/net/ircomm/ircomm_core.c | 8 ++++----
drivers/staging/irda/net/ircomm/ircomm_tty.c | 2 +-
drivers/staging/irda/net/irlan/irlan_common.c | 3 +--
drivers/staging/irda/net/irlmp.c | 2 +-
4 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/irda/net/ircomm/ircomm_core.c b/drivers/staging/irda/net/ircomm/ircomm_core.c
index 6c02fbf380bd..9bb2ff306470 100644
--- a/drivers/staging/irda/net/ircomm/ircomm_core.c
+++ b/drivers/staging/irda/net/ircomm/ircomm_core.c
@@ -530,13 +530,13 @@ static int ircomm_seq_show(struct seq_file *seq, void *v)
self->slsap_sel, self->dlsap_sel);
if(self->service_type & IRCOMM_3_WIRE_RAW)
- seq_printf(seq, " 3-wire-raw");
+ seq_puts(seq, " 3-wire-raw");
if(self->service_type & IRCOMM_3_WIRE)
- seq_printf(seq, " 3-wire");
+ seq_puts(seq, " 3-wire");
if(self->service_type & IRCOMM_9_WIRE)
- seq_printf(seq, " 9-wire");
+ seq_puts(seq, " 9-wire");
if(self->service_type & IRCOMM_CENTRONICS)
- seq_printf(seq, " Centronics");
+ seq_puts(seq, " Centronics");
seq_putc(seq, '\n');
return 0;
diff --git a/drivers/staging/irda/net/ircomm/ircomm_tty.c b/drivers/staging/irda/net/ircomm/ircomm_tty.c
index d1beec413fa3..dc7097576917 100644
--- a/drivers/staging/irda/net/ircomm/ircomm_tty.c
+++ b/drivers/staging/irda/net/ircomm/ircomm_tty.c
@@ -1174,7 +1174,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
seq_printf(m, "Port name: %s\n", self->settings.port_name);
- seq_printf(m, "DTE status:");
+ seq_puts(m, "DTE status:");
sep = ' ';
if (self->settings.dte & IRCOMM_RTS) {
seq_printf(m, "%cRTS", sep);
diff --git a/drivers/staging/irda/net/irlan/irlan_common.c b/drivers/staging/irda/net/irlan/irlan_common.c
index 481bbc2a4349..f4633d4dc390 100644
--- a/drivers/staging/irda/net/irlan/irlan_common.c
+++ b/drivers/staging/irda/net/irlan/irlan_common.c
@@ -1138,8 +1138,7 @@ static int irlan_seq_show(struct seq_file *seq, void *v)
seq_printf(seq,"media: %s\n",
irlan_media[self->media]);
- seq_printf(seq,"local filter:\n");
- seq_printf(seq,"remote filter: ");
+ seq_puts(seq, "local filter:\nremote filter: ");
irlan_print_filter(seq, self->client.filter_type);
seq_printf(seq,"tx busy: %s\n",
netif_queue_stopped(self->dev) ? "TRUE" : "FALSE");
diff --git a/drivers/staging/irda/net/irlmp.c b/drivers/staging/irda/net/irlmp.c
index 6a09cf621bd4..60a3dd7d6f49 100644
--- a/drivers/staging/irda/net/irlmp.c
+++ b/drivers/staging/irda/net/irlmp.c
@@ -1937,7 +1937,7 @@ static int irlmp_seq_show(struct seq_file *seq, void *v)
* the object spinlock, so we are safe. Jean II */
spin_lock(&lap->lsaps->hb_spinlock);
- seq_printf(seq, "\n Connected LSAPs:\n");
+ seq_puts(seq, "\n Connected LSAPs:\n");
for (self = (struct lsap_cb *) hashbin_get_first(lap->lsaps);
self;
self = (struct lsap_cb *)hashbin_get_next(lap->lsaps)) {
--
2.14.2
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 00/10] staging/irda/net: Adjustments for several function implementations
2017-10-12 10:38 [PATCH 00/10] staging/irda/net: Adjustments for several function implementations SF Markus Elfring
` (8 preceding siblings ...)
2017-10-12 10:50 ` [PATCH 10/10] staging/irda/net: Use seq_puts() in four functions SF Markus Elfring
@ 2017-10-12 11:17 ` Bjørn Mork
2017-10-12 13:45 ` SF Markus Elfring
9 siblings, 1 reply; 12+ messages in thread
From: Bjørn Mork @ 2017-10-12 11:17 UTC (permalink / raw)
To: SF Markus Elfring
Cc: devel, netdev, Al Viro, Corentin Labbe, David Howells,
David S. Miller, Georgiana Chelu, Greg Kroah-Hartman,
Johannes Berg, Julia Lawall, Samuel Ortiz, Srishti Sharma,
Stephen Hemminger, Yuan Linyu, LKML, kernel-janitors
Did you read drivers/staging/irda/TODO ?
There is no need to answer that. You already have. Thanks a lot for
your ever lasting invaluable contributions to /dev/null. Please
continue.
Bjørn
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: staging/irda/net: Adjustments for several function implementations
2017-10-12 11:17 ` [PATCH 00/10] staging/irda/net: Adjustments for several function implementations Bjørn Mork
@ 2017-10-12 13:45 ` SF Markus Elfring
0 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2017-10-12 13:45 UTC (permalink / raw)
To: Bjørn Mork, devel, netdev
Cc: Al Viro, Corentin Labbe, David Howells, David S. Miller,
Georgiana Chelu, Greg Kroah-Hartman, Johannes Berg, Julia Lawall,
Samuel Ortiz, Srishti Sharma, Stephen Hemminger, Yuan Linyu, LKML,
kernel-janitors
> Did you read drivers/staging/irda/TODO ?
Yes.
How do recent contributions (by other software developers) fit to information
that is provided in this file?
Regards,
Markus
^ permalink raw reply [flat|nested] 12+ messages in thread