Remove unnecessary null pointer checks?
Subsystems (270)
PATCH 2/9 staging: ks7010: Delete unnecessary assignments for buffer variables
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 13:38:46 +0200
A few variables were assigned a null pointer despite of the detail that they were immediately reassigned by the following statement. Thus remove such unnecessary assignments.
--- drivers/staging/ks7010/ks7010_sdio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +1 -4
@@ -711,7 +711,6 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)int rc =0 ;int retval;unsigned char *data_buf; - data_buf =NULL ; data_buf =kmalloc (sizeof (u32),GFP_KERNEL );if (!data_buf) {
@@ -743,7 +742,7 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,int rc =0 ;int retval;unsigned char *read_buf; - read_buf =NULL ; + read_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL );if (!read_buf) { rc =1 ;
@@ -776,8 +775,6 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,int length;const struct firmware *fw_entry =NULL ; - rom_buf =NULL ; -/* buffer allocate */ rom_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL );if (!rom_buf) {
Signature · 1 line
2.9.1
PATCH 3/9 staging: ks7010: Return directly after a failed kmalloc()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 15:55:02 +0200
Return directly after a memory allocation failed at the beginning.
--- drivers/staging/ks7010/ks7010_sdio.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +7 -12
@@ -713,10 +713,8 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)unsigned char *data_buf; data_buf =kmalloc (sizeof (u32),GFP_KERNEL ); -if (!data_buf) { - rc =1 ; - goto error_out; - } +if (!data_buf) +return 1 ;memcpy (data_buf, &index,sizeof (index)); retval =ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index));
@@ -744,10 +742,9 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,unsigned char *read_buf; read_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL ); -if (!read_buf) { - rc =1 ; - goto error_out; - } +if (!read_buf) +return 1 ; + retval =ks7010_sdio_read (priv, address, read_buf, size);if (retval) { rc =2 ;
@@ -777,10 +774,8 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,/* buffer allocate */ rom_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL ); -if (!rom_buf) { - rc =3 ; - goto error_out0; - } +if (!rom_buf) +return 3 ;sdio_claim_host (card->func);
Signature · 1 line
2.9.1
PATCH 4/9 staging: ks7010: Rename jump labels
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 16:26:18 +0200
Adjust jump targets according to the Linux coding style convention.
--- drivers/staging/ks7010/ks7010_sdio.c | 81 +++++++++++++++++------------------- 1 file changed, 38 insertions(+), 43 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +38 -43
@@ -113,7 +113,7 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)DPRINTK (1 ,"sleep_mode=%d\n" , priv->sleep_mode); } - out: +out: priv->sleep_mode =atomic_read (&priv->sleepstatus.status);return ; }
@@ -144,7 +144,7 @@ void ks_wlan_hw_sleep_wakeup_request(struct ks_wlan_private *priv)DPRINTK (1 ,"sleep_mode=%d\n" , priv->sleep_mode); } - out: +out: priv->sleep_mode =atomic_read (&priv->sleepstatus.status);return ; }
@@ -480,7 +480,7 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)/* rx_event_task((void *)priv); */ tasklet_schedule (&priv->ks_wlan_hw.rx_bh_task); - error_out: +error_out:return ; }
@@ -523,18 +523,18 @@ static void ks7010_rw_function(struct work_struct *work)queue_delayed_work (priv->ks_wlan_hw.ks7010sdio_wq, &priv->ks_wlan_hw.rw_wq,1 ); } - goto err_out; + goto release_host; }/* sleep mode doze */ if (atomic_read (&priv->sleepstatus.doze_request) =1 ) {ks_wlan_hw_sleep_doze_request (priv); - goto err_out; + goto release_host; }/* sleep mode wakeup */ if (atomic_read (&priv->sleepstatus.wakeup_request) =1 ) {ks_wlan_hw_sleep_wakeup_request (priv); - goto err_out; + goto release_host; }/* read (WriteStatus/ReadDataSize FN1:00_0014) */
@@ -543,7 +543,7 @@ static void ks7010_rw_function(struct work_struct *work)if (retval) {DPRINTK (1 ," error : WSTATUS_RSIZE=%02X psstatus=%d\n" , rw_data,atomic_read (&priv->psstatus.status)); - goto err_out; + goto release_host; }DPRINTK (4 ,"WSTATUS_RSIZE=%02X\n" , rw_data);
@@ -555,8 +555,7 @@ static void ks7010_rw_function(struct work_struct *work)tx_device_task ((void *)priv); }_ks_wlan_hw_power_save (priv); - - err_out: +release_host:sdio_release_host (priv->ks_wlan_hw.sdio_card->func);return ;
@@ -664,7 +663,7 @@ static void ks_sdio_interrupt(struct sdio_func *func) }while (rsize); } - intr_out: +intr_out:queue_delayed_work (priv->ks_wlan_hw.ks7010sdio_wq, &priv->ks_wlan_hw.rw_wq,0 );return ;
@@ -720,15 +719,13 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) retval =ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index));if (retval) { rc =2 ; - goto error_out; + goto free_buf; } retval =ks7010_sdio_write (priv,READ_INDEX , data_buf,sizeof (index)); -if (retval) { +if (retval) rc =3 ; - goto error_out; - } - error_out: +free_buf:kfree (data_buf);return rc; }
@@ -748,16 +745,15 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address, retval =ks7010_sdio_read (priv, address, read_buf, size);if (retval) { rc =2 ; - goto error_out; + goto free_buf; } retval =memcmp (data, read_buf, size);if (retval) {DPRINTK (0 ,"data compare error (%d) \n" , retval); rc =3 ; - goto error_out; } - error_out: +free_buf:kfree (read_buf);return rc; }
@@ -784,7 +780,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,if (rw_data =GCR_A_RUN ) {DPRINTK (0 ,"MAC firmware running ...\n" ); rc =0 ; - goto error_out0; + goto release_host; } retval =request_firmware (&fw_entry,ROM_FILE , &priv->ks_wlan_hw.sdio_card->func->dev);
@@ -814,14 +810,14 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv, KS7010_IRAM_ADDRESS + offset);if (retval) { rc =6 ; - goto error_out1; + goto release_fw; }/* Write data */ retval =ks7010_sdio_write (priv,DATA_WINDOW , rom_buf, size);if (retval) { rc =8 ; - goto error_out1; + goto release_fw; }/* compare */
@@ -829,7 +825,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,ks7010_sdio_data_compare (priv,DATA_WINDOW , rom_buf, size);if (retval) { rc =9 ; - goto error_out1; + goto release_fw; } n += size;
@@ -840,7 +836,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv, retval =ks7010_sdio_write (priv,GCR_A , &rw_data,sizeof (rw_data));if (retval) { rc =11 ; - goto error_out1; + goto release_fw; }DPRINTK (4 ," REMAP Request : GCR_A=%02X\n" , rw_data);
@@ -851,7 +847,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,ks7010_sdio_read (priv,GCR_A , &rw_data,sizeof (rw_data));if (retval) { rc =11 ; - goto error_out1; + goto release_fw; }if (rw_data =GCR_A_RUN )break ;
@@ -860,14 +856,13 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,if ((50 ) <= n) {DPRINTK (1 ,"firmware can't start\n" ); rc =12 ; - goto error_out1; + goto release_fw; } rc =0 ; - - error_out1: +release_fw:release_firmware (fw_entry); - error_out0: +release_host:sdio_release_host (card->func);kfree (rom_buf);return rc;
@@ -994,20 +989,20 @@ static int ks7010_sdio_probe(struct sdio_func *func, ret =sdio_enable_func (func);DPRINTK (5 ,"sdio_enable_func() %d\n" , ret);if (ret) - goto error_free_card; + goto free_card;/* interrupt disable */ sdio_writeb (func,0 ,INT_ENABLE , &ret);if (ret) - goto error_free_card; + goto free_card;sdio_writeb (func,0xff ,INT_PENDING , &ret);if (ret) - goto error_disable_func; + goto disable_func;/* setup interrupt handler */ ret =sdio_claim_irq (func, ks_sdio_interrupt);if (ret) - goto error_disable_func; + goto disable_func;sdio_release_host (func);
@@ -1020,11 +1015,11 @@ static int ks7010_sdio_probe(struct sdio_func *func, netdev =alloc_etherdev (sizeof (*priv));if (netdev =NULL ) {printk (KERN_ERR "ks7010 : Unable to alloc new net device\n" ); - goto error_release_irq; + goto release_irq; }if (dev_alloc_name (netdev,"wlan%d" ) <0 ) {printk (KERN_ERR "ks7010 : Couldn't get name!\n" ); - goto error_free_netdev; + goto free_dev; } priv =netdev_priv (netdev);
@@ -1038,7 +1033,7 @@ static int ks7010_sdio_probe(struct sdio_func *func, priv->ks_wlan_hw.read_buf =NULL ; priv->ks_wlan_hw.read_buf =kmalloc (RX_DATA_SIZE ,GFP_KERNEL );if (!priv->ks_wlan_hw.read_buf) { - goto error_free_netdev; + goto free_dev; } priv->dev_state =DEVICE_STATE_PREBOOT ; priv->net_dev = netdev;
@@ -1066,7 +1061,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,printk (KERN_ERR "ks7010: firmware load failed !! retern code = %d\n" , ret); - goto error_free_read_buf; + goto free_buf; }/* interrupt setting */
@@ -1094,7 +1089,7 @@ static int ks7010_sdio_probe(struct sdio_func *func, priv->ks_wlan_hw.ks7010sdio_wq =create_workqueue ("ks7010sdio_wq" );if (!priv->ks_wlan_hw.ks7010sdio_wq) {DPRINTK (1 ,"create_workqueue failed !!\n" ); - goto error_free_read_buf; + goto free_buf; }INIT_DELAYED_WORK (&priv->ks_wlan_hw.rw_wq, ks7010_rw_function);
@@ -1102,22 +1097,22 @@ static int ks7010_sdio_probe(struct sdio_func *func, ret =register_netdev (priv->net_dev);if (ret) - goto error_free_read_buf; + goto free_buf;return 0 ; - error_free_read_buf: +free_buf:kfree (priv->ks_wlan_hw.read_buf); priv->ks_wlan_hw.read_buf =NULL ; - error_free_netdev: +free_dev:free_netdev (priv->net_dev); card->priv =NULL ; - error_release_irq: +release_irq:sdio_claim_host (func);sdio_release_irq (func); - error_disable_func: +disable_func:sdio_disable_func (func); - error_free_card: +free_card:sdio_release_host (func);sdio_set_drvdata (func,NULL );kfree (card);
Signature · 1 line
2.9.1
PATCH 5/9 staging: ks7010: Delete unnecessary uses of the variable "retval"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 18:15:23 +0200
Some return values can also be directly used for various condition checks. Thus remove a local variable for intermediate assignments.
--- drivers/staging/ks7010/ks7010_sdio.c | 81 +++++++++++++++--------------------- 1 file changed, 34 insertions(+), 47 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +34 -38
@@ -90,7 +90,6 @@ static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address,void ks_wlan_hw_sleep_doze_request (struct ks_wlan_private *priv) {unsigned char rw_data; -int retval;DPRINTK (4 ,"\n" );
@@ -99,9 +98,10 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)if (atomic_read (&priv->sleepstatus.status) =0 ) { rw_data =GCR_B_DOZE ; - retval -ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {DPRINTK (1 ," error : GCR_B=%02X\n" , rw_data); goto out; }
@@ -121,7 +121,6 @@ out:void ks_wlan_hw_sleep_wakeup_request (struct ks_wlan_private *priv) {unsigned char rw_data; -int retval;DPRINTK (4 ,"\n" );
@@ -130,9 +129,10 @@ void ks_wlan_hw_sleep_wakeup_request(struct ks_wlan_private *priv)if (atomic_read (&priv->sleepstatus.status) =1 ) { rw_data =WAKEUP_REQ ; - retval -ks7010_sdio_write (priv,WAKEUP , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +WAKEUP , + &rw_data, +sizeof (rw_data))) {DPRINTK (1 ," error : WAKEUP=%02X\n" , rw_data); goto out; }
@@ -152,16 +152,15 @@ out:void ks_wlan_hw_wakeup_request (struct ks_wlan_private *priv) {unsigned char rw_data; -int retval;DPRINTK (4 ,"\n" );if (atomic_read (&priv->psstatus.status) =PS_SNOOZE ) { rw_data =WAKEUP_REQ ; - retval -ks7010_sdio_write (priv,WAKEUP , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +WAKEUP , + &rw_data, +sizeof (rw_data)))DPRINTK (1 ," error : WAKEUP=%02X\n" , rw_data); - }DPRINTK (4 ,"wake up : WAKEUP=%02X\n" , rw_data); priv->last_wakeup = jiffies; ++priv->wakeup_count;
@@ -175,7 +174,6 @@ int _ks_wlan_hw_power_save(struct ks_wlan_private *priv) {int rc =0 ;unsigned char rw_data; -int retval;if (priv->reg.powermgt =POWMGT_ACTIVE_MODE )return rc;
@@ -198,11 +196,11 @@ int _ks_wlan_hw_power_save(struct ks_wlan_private *priv)if (!atomic_read (&priv->psstatus.confirm_wait) && !atomic_read (&priv->psstatus.snooze_guard) && !cnt_txqbody (priv)) { - retval -ks7010_sdio_read (priv,INT_PENDING , +if (ks7010_sdio_read (priv, +INT_PENDING , &rw_data, -sizeof (rw_data)); -if (retval) { +sizeof (rw_data)) + ) {DPRINTK (1 ," error : INT_PENDING=%02X\n" , rw_data);
@@ -212,12 +210,11 @@ int _ks_wlan_hw_power_save(struct ks_wlan_private *priv) }if (!rw_data) { rw_data =GCR_B_DOZE ; - retval -ks7010_sdio_write (priv, +if (ks7010_sdio_write (priv,GCR_B , &rw_data, -sizeof (rw_data)); -if (retval) { +sizeof (rw_data)) + ) {DPRINTK (1 ," error : GCR_B=%02X\n" , rw_data);
@@ -413,7 +410,6 @@ static void rx_event_task(unsigned long dev)static void ks_wlan_hw_rx (void *dev,uint16_t size) {struct ks_wlan_private *priv = (struct ks_wlan_private *)dev; -int retval;struct rx_device_buffer *rx_buffer;struct hostif_hdr *hdr;unsigned char read_status;
@@ -429,12 +425,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size) } rx_buffer = &priv->rx_dev.rx_dev_buff[priv->rx_dev.qtail]; - retval -ks7010_sdio_read (priv,DATA_WINDOW , &rx_buffer->data[0 ], -hif_align_size (size)); -if (retval) { +if (ks7010_sdio_read (priv, +DATA_WINDOW , + &rx_buffer->data[0 ], +hif_align_size (size))) goto error_out; - }/* length check */ if (size >2046 || size =0 ) {
@@ -446,12 +441,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)#endif /* rx_status update */ read_status =READ_STATUS_IDLE ; - retval -ks7010_sdio_write (priv,READ_STATUS , &read_status, -sizeof (read_status)); -if (retval) { +if (ks7010_sdio_write (priv, +READ_STATUS , + &read_status, +sizeof (read_status)))DPRINTK (1 ," error : READ_STATUS=%02X\n" , read_status); - } goto error_out; }
@@ -462,12 +456,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)/* read status update */ read_status =READ_STATUS_IDLE ; - retval -ks7010_sdio_write (priv,READ_STATUS , &read_status, -sizeof (read_status)); -if (retval) { +if (ks7010_sdio_write (priv, +READ_STATUS , + &read_status, +sizeof (read_status)))DPRINTK (1 ," error : READ_STATUS=%02X\n" , read_status); - }DPRINTK (4 ,"READ_STATUS=%02X\n" , read_status);if (atomic_read (&priv->psstatus.confirm_wait)) {
@@ -489,7 +482,6 @@ static void ks7010_rw_function(struct work_struct *work)struct hw_info_t *hw;struct ks_wlan_private *priv;unsigned char rw_data; -int retval; hw = container_of(work, struct hw_info_t, rw_wq.work); priv = container_of(hw, struct ks_wlan_private, ks_wlan_hw);
@@ -538,9 +530,7 @@ static void ks7010_rw_function(struct work_struct *work) }/* read (WriteStatus/ReadDataSize FN1:00_0014) */ - retval -ks7010_sdio_read (priv,WSTATUS_RSIZE , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_read (priv,WSTATUS_RSIZE , &rw_data,sizeof (rw_data))) {DPRINTK (1 ," error : WSTATUS_RSIZE=%02X psstatus=%d\n" , rw_data,atomic_read (&priv->psstatus.status)); goto release_host;
@@ -708,7 +698,6 @@ static void trx_device_exit(struct ks_wlan_private *priv)static int ks7010_sdio_update_index (struct ks_wlan_private *priv,u32 index) {int rc =0 ; -int retval;unsigned char *data_buf; data_buf =kmalloc (sizeof (u32),GFP_KERNEL );
@@ -716,14 +705,12 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)return 1 ;memcpy (data_buf, &index,sizeof (index)); - retval =ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index)); -if (retval) { +if (ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index))) { rc =2 ; goto free_buf; } - retval =ks7010_sdio_write (priv,READ_INDEX , data_buf,sizeof (index)); -if (retval) +if (ks7010_sdio_write (priv,READ_INDEX , data_buf,sizeof (index))) rc =3 ; free_buf:kfree (data_buf);
Signature · 1 line
2.9.1
PATCH 6/9 staging: ks7010: Delete unnecessary braces
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 18:39:03 +0200
Do not use curly brackets at some source code places where a single statement should be sufficient.
--- drivers/staging/ks7010/ks7010_sdio.c | 48 ++++++++++++------------------------ 1 file changed, 16 insertions(+), 32 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +16 -32
@@ -109,9 +109,8 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)DPRINTK (3 ,"sleep_mode=SLP_SLEEP\n" );atomic_set (&priv->sleepstatus.status,1 ); priv->last_doze = jiffies; - }else { + }else DPRINTK (1 ,"sleep_mode=%d\n" , priv->sleep_mode); - } out: priv->sleep_mode =atomic_read (&priv->sleepstatus.status);
@@ -140,9 +139,8 @@ void ks_wlan_hw_sleep_wakeup_request(struct ks_wlan_private *priv)atomic_set (&priv->sleepstatus.status,0 ); priv->last_wakeup = jiffies; ++priv->wakeup_count; - }else { + }else DPRINTK (1 ,"sleep_mode=%d\n" , priv->sleep_mode); - } out: priv->sleep_mode =atomic_read (&priv->sleepstatus.status);
@@ -164,10 +162,9 @@ void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv)DPRINTK (4 ,"wake up : WAKEUP=%02X\n" , rw_data); priv->last_wakeup = jiffies; ++priv->wakeup_count; - }else { + }else DPRINTK (1 ,"psstatus=%d\n" ,atomic_read (&priv->psstatus.status)); - } }int _ks_wlan_hw_power_save (struct ks_wlan_private *priv)
@@ -380,10 +377,9 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, result =enqueue_txdev (priv, p, size, complete_handler, arg1, arg2);spin_unlock (&priv->tx_dev.tx_dev_lock); -if (cnt_txqbody (priv) >0 ) { +if (cnt_txqbody (priv) >0 )queue_delayed_work (priv->ks_wlan_hw.ks7010sdio_wq, &priv->ks_wlan_hw.rw_wq,0 ); - }return result; }
@@ -399,9 +395,8 @@ static void rx_event_task(unsigned long dev)hostif_receive (priv, rp->data, rp->size);inc_rxqhead (priv); -if (cnt_rxqbody (priv) >0 ) { +if (cnt_rxqbody (priv) >0 )tasklet_schedule (&priv->ks_wlan_hw.rx_bh_task); - } }return ;
@@ -463,12 +458,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)DPRINTK (1 ," error : READ_STATUS=%02X\n" , read_status);DPRINTK (4 ,"READ_STATUS=%02X\n" , read_status); -if (atomic_read (&priv->psstatus.confirm_wait)) { +if (atomic_read (&priv->psstatus.confirm_wait))if (IS_HIF_CONF (event)) {DPRINTK (4 ,"IS_HIF_CONF true !!\n" );atomic_dec (&priv->psstatus.confirm_wait); } - }/* rx_event_task((void *)priv); */ tasklet_schedule (&priv->ks_wlan_hw.rx_bh_task);
@@ -537,13 +531,11 @@ static void ks7010_rw_function(struct work_struct *work) }DPRINTK (4 ,"WSTATUS_RSIZE=%02X\n" , rw_data); -if (rw_data &RSIZE_MASK ) {/* Read schedule */ +if (rw_data &RSIZE_MASK )/* Read schedule */ ks_wlan_hw_rx ((void *)priv, (uint16_t ) (((rw_data &RSIZE_MASK ) <<4 ))); - } -if ((rw_data &WSTATUS_MASK )) { +if (rw_data &WSTATUS_MASK )tx_device_task ((void *)priv); - }_ks_wlan_hw_power_save (priv); release_host:sdio_release_host (priv->ks_wlan_hw.sdio_card->func);
@@ -611,10 +603,9 @@ static void ks_sdio_interrupt(struct sdio_func *func) }DPRINTK (4 ,"WSTATUS_RSIZE=%02X\n" , rw_data); rsize = rw_data &RSIZE_MASK ; -if (rsize) {/* Read schedule */ +if (rsize)/* Read schedule */ ks_wlan_hw_rx ((void *)priv, (uint16_t ) (((rsize) <<4 ))); - }if (rw_data &WSTATUS_MASK ) {#if 0 if (status & INT_WRITE_STATUS
@@ -625,11 +616,10 @@ static void ks_sdio_interrupt(struct sdio_func *func)ks7010_sdio_write (priv,DATA_WINDOW , &rw_data,sizeof (rw_data)); -if (retval) { +if (retval)DPRINTK (1 ,"write DATA_WINDOW Failed!!(%d)\n" , retval); - } status &= ~INT_WRITE_STATUS; }else {#endif
@@ -870,13 +860,11 @@ static void ks7010_card_init(struct ks_wlan_private *priv)DPRINTK (5 ,"hostif_sme_enqueu()\n" );if (!wait_for_completion_interruptible_timeout - (&priv->confirm_wait,5 *HZ )) { + (&priv->confirm_wait,5 *HZ ))DPRINTK (1 ,"wait time out!! SME_START\n" ); - } -if (priv->mac_address_valid && priv->version_size) { +if (priv->mac_address_valid && priv->version_size) priv->dev_state =DEVICE_STATE_PREINIT ; - }hostif_sme_enqueue (priv,SME_GET_EEPROM_CKSUM );
@@ -898,16 +886,14 @@ static void ks7010_card_init(struct ks_wlan_private *priv)hostif_sme_enqueue (priv,SME_START_REQUEST );if (!wait_for_completion_interruptible_timeout - (&priv->confirm_wait,5 *HZ )) { + (&priv->confirm_wait,5 *HZ ))DPRINTK (1 ,"wait time out!! wireless parameter set\n" ); - }if (priv->dev_state >=DEVICE_STATE_PREINIT ) {DPRINTK (1 ,"DEVICE READY!!\n" ); priv->dev_state =DEVICE_STATE_READY ; - }else { + }else DPRINTK (1 ,"dev_state=%d\n" , priv->dev_state); - } }static void ks7010_init_defaults (struct ks_wlan_private *priv)
@@ -1057,9 +1043,8 @@ static int ks7010_sdio_probe(struct sdio_func *func,sdio_claim_host (func); ret =ks7010_sdio_write (priv,INT_PENDING , &rw_data,sizeof (rw_data));sdio_release_host (func); -if (ret) { +if (ret)DPRINTK (1 ," error : INT_PENDING=%02X\n" , rw_data); - }DPRINTK (4 ," clear Interrupt : INT_PENDING=%02X\n" , rw_data);/* enable ks7010sdio interrupt (INT_GCR_B|INT_READ_STATUS|INT_WRITE_STATUS) */
@@ -1067,9 +1052,8 @@ static int ks7010_sdio_probe(struct sdio_func *func,sdio_claim_host (func); ret =ks7010_sdio_write (priv,INT_ENABLE , &rw_data,sizeof (rw_data));sdio_release_host (func); -if (ret) { +if (ret)DPRINTK (1 ," error : INT_ENABLE=%02X\n" , rw_data); - }DPRINTK (4 ," enable Interrupt : INT_ENABLE=%02X\n" , rw_data); priv->dev_state =DEVICE_STATE_BOOT ;
Signature · 1 line
2.9.1
PATCH 7/9 staging: ks7010: Replace three printk() calls by pr_err()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 19:12:27 +0200
Prefer usage of the macro "pr_err" over the interface "printk". Fix a typo in an error message.
--- drivers/staging/ks7010/ks7010_sdio.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +3 -4
@@ -987,11 +987,11 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* private memory allocate */ netdev =alloc_etherdev (sizeof (*priv));if (netdev =NULL ) { -printk (KERN_ERR "ks7010 : Unable to alloc new net device\n" ); +pr_err ("ks7010: Unable to alloc new net device\n" ); goto release_irq; }if (dev_alloc_name (netdev,"wlan%d" ) <0 ) { -printk (KERN_ERR "ks7010 : Couldn't get name!\n" ); +pr_err ("ks7010: Couldn't get name!\n" ); goto free_dev; }
@@ -1031,8 +1031,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* Upload firmware */ ret =ks7010_upload_firmware (priv, card);/* firmware load */ if (ret) { -printk (KERN_ERR -"ks7010: firmware load failed !! retern code = %d\n" , +pr_err ("ks7010: firmware load failed! return code = %d\n" , ret); goto free_buf; }
Signature · 1 line
2.9.1
PATCH 8/9 staging: ks7010: Delete a variable in write_to_device()
In reply to SF Markus ElfringFrom 01291121668ccb54f1a784765a8d2b5811afa75a Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 19:26:15 +0200
Subject: [PATCH 8/9] staging: ks7010: Delete a variable in write_to_device()
The local variable "rc" was assigned a zero at one place. But it was not read within this function. Thus delete it.
--- drivers/staging/ks7010/ks7010_sdio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +1 -2
@@ -291,11 +291,10 @@ static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p,static int write_to_device (struct ks_wlan_private *priv,unsigned char *buffer,unsigned long size) { -int rc, retval; +int retval;unsigned char rw_data;struct hostif_hdr *hdr; hdr = (struct hostif_hdr *)buffer; - rc =0 ;DPRINTK (4 ,"size=%d\n" , hdr->size);if (hdr->event <HIF_DATA_REQ ||HIF_REQ_MAX < hdr->event) {
Signature · 1 line
2.9.1
PATCH 9/9 staging: ks7010: Delete three unnecessary variable initialisations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 19:40:47 +0200
Three variables will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.
--- drivers/staging/ks7010/ks7010_sdio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +4 -4
@@ -323,14 +323,14 @@ static void tx_device_task(void *dev) {struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;struct tx_device_buffer *sp; -int rc =0 ;DPRINTK (4 ,"\n" );if (cnt_txqbody (priv) >0 &&atomic_read (&priv->psstatus.status) !=PS_SNOOZE ) { sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead];if (priv->dev_state >=DEVICE_STATE_BOOT ) { - rc =write_to_device (priv, sp->sendp, sp->size); +int rc =write_to_device (priv, sp->sendp, sp->size); +if (rc) {DPRINTK (1 ,"write_to_device error !!(%d)\n" , rc);
@@ -358,7 +358,7 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size,void (*complete_handler) (void *arg1,void *arg2), void *arg1, void *arg2) { - int result = 0; + int result;struct hostif_hdr *hdr; hdr = (struct hostif_hdr *)p;
@@ -737,7 +737,7 @@ free_buf:static int ks7010_upload_firmware (struct ks_wlan_private *priv,struct ks_sdio_card *card) { -unsigned int size, offset, n =0 ; +unsigned int size, offset, n;unsigned char *rom_buf;unsigned char rw_data =0 ;int retval, rc =0 ;
Signature · 1 line
2.9.1
Re: [PATCH 9/9] staging: ks7010: Delete three unnecessary variable initialisations
Quoted 18 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 19:40:47 +0200Three variables will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +0
-0@@ -323,14 +323,14 @@ static void tx_device_task(void *dev) {struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;
drivers/staging/ks7010/ks7010_sdio.c static void tx_device_task(void *dev) · line 332
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-2struct tx_device_buffer *sp; -int rc =0 ;DPRINTK (4 ,"\n" );if (cnt_txqbody (priv) >0 &&atomic_read (&priv->psstatus.status) !=PS_SNOOZE ) { sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead];if (priv->dev_state >=DEVICE_STATE_BOOT ) { - rc =write_to_device (priv, sp->sendp, sp->size); +int rc =write_to_device (priv, sp->sendp, sp->size);
This does not look appealing to me, neither the declaration in the middle of the function, nor the intiialization to the result of a complex expression, nor the separation of the call and the error checking code by a blank line. There is nothing wrong with having the rc variable be declared at the the top of the function, in its normal place.
julia
Quoted 30 lines
drivers/staging/ks7010/ks7010_sdio.c +3
-3+if (rc) {DPRINTK (1 ,"write_to_device error !!(%d)\n" , rc);@@ -358,7 +358,7 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size,void (*complete_handler) (void *arg1,void *arg2), void *arg1, void *arg2) { - int result = 0; + int result;struct hostif_hdr *hdr; hdr = (struct hostif_hdr *)p;@@ -737,7 +737,7 @@ free_buf:static int ks7010_upload_firmware (struct ks_wlan_private *priv,struct ks_sdio_card *card) { -unsigned int size, offset, n =0 ; +unsigned int size, offset, n;unsigned char *rom_buf;unsigned char rw_data =0 ;int retval, rc =0 ; --2.9.1
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 6/9] staging: ks7010: Delete unnecessary braces
In reply to SF Markus ElfringQuoted 16 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 18:39:03 +0200Do not use curly brackets at some source code places where a single statement should be sufficient.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 48 ++++++++++++------------------------ 1 file changed, 16 insertions(+), 32 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +0
-0
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 114
Quoted 7 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-2@@ -109,9 +109,8 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)DPRINTK (3 ,"sleep_mode=SLP_SLEEP\n" );atomic_set (&priv->sleepstatus.status,1 ); priv->last_doze = jiffies; - }else { + }else DPRINTK (1 ,"sleep_mode=%d\n" , priv->sleep_mode); - }
This is a violation of CodingStyle:
This does not apply if only one branch of a conditional statement is a single
statement; in the latter case use braces in both branches:
if (condition) {
do_this();
do_that();
} else {
otherwise();
}julia
Quoted 169 lines
drivers/staging/ks7010/ks7010_sdio.c +15
-31out: priv->sleep_mode =atomic_read (&priv->sleepstatus.status);@@ -140,9 +139,8 @@ void ks_wlan_hw_sleep_wakeup_request(struct ks_wlan_private *priv)atomic_set (&priv->sleepstatus.status,0 ); priv->last_wakeup = jiffies; ++priv->wakeup_count; - }else { + }else DPRINTK (1 ,"sleep_mode=%d\n" , priv->sleep_mode); - } out: priv->sleep_mode =atomic_read (&priv->sleepstatus.status);@@ -164,10 +162,9 @@ void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv)DPRINTK (4 ,"wake up : WAKEUP=%02X\n" , rw_data); priv->last_wakeup = jiffies; ++priv->wakeup_count; - }else { + }else DPRINTK (1 ,"psstatus=%d\n" ,atomic_read (&priv->psstatus.status)); - } }int _ks_wlan_hw_power_save (struct ks_wlan_private *priv)@@ -380,10 +377,9 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, result =enqueue_txdev (priv, p, size, complete_handler, arg1, arg2);spin_unlock (&priv->tx_dev.tx_dev_lock); -if (cnt_txqbody (priv) >0 ) { +if (cnt_txqbody (priv) >0 )queue_delayed_work (priv->ks_wlan_hw.ks7010sdio_wq, &priv->ks_wlan_hw.rw_wq,0 ); - }return result; }@@ -399,9 +395,8 @@ static void rx_event_task(unsigned long dev)hostif_receive (priv, rp->data, rp->size);inc_rxqhead (priv); -if (cnt_rxqbody (priv) >0 ) { +if (cnt_rxqbody (priv) >0 )tasklet_schedule (&priv->ks_wlan_hw.rx_bh_task); - } }return ;@@ -463,12 +458,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)DPRINTK (1 ," error : READ_STATUS=%02X\n" , read_status);DPRINTK (4 ,"READ_STATUS=%02X\n" , read_status); -if (atomic_read (&priv->psstatus.confirm_wait)) { +if (atomic_read (&priv->psstatus.confirm_wait))if (IS_HIF_CONF (event)) {DPRINTK (4 ,"IS_HIF_CONF true !!\n" );atomic_dec (&priv->psstatus.confirm_wait); } - }/* rx_event_task((void *)priv); */ tasklet_schedule (&priv->ks_wlan_hw.rx_bh_task);@@ -537,13 +531,11 @@ static void ks7010_rw_function(struct work_struct *work) }DPRINTK (4 ,"WSTATUS_RSIZE=%02X\n" , rw_data); -if (rw_data &RSIZE_MASK ) {/* Read schedule */ +if (rw_data &RSIZE_MASK )/* Read schedule */ ks_wlan_hw_rx ((void *)priv, (uint16_t ) (((rw_data &RSIZE_MASK ) <<4 ))); - } -if ((rw_data &WSTATUS_MASK )) { +if (rw_data &WSTATUS_MASK )tx_device_task ((void *)priv); - }_ks_wlan_hw_power_save (priv); release_host:sdio_release_host (priv->ks_wlan_hw.sdio_card->func);@@ -611,10 +603,9 @@ static void ks_sdio_interrupt(struct sdio_func *func) }DPRINTK (4 ,"WSTATUS_RSIZE=%02X\n" , rw_data); rsize = rw_data &RSIZE_MASK ; -if (rsize) {/* Read schedule */ +if (rsize)/* Read schedule */ ks_wlan_hw_rx ((void *)priv, (uint16_t ) (((rsize) <<4 ))); - }if (rw_data &WSTATUS_MASK ) {#if 0 if (status & INT_WRITE_STATUS@@ -625,11 +616,10 @@ static void ks_sdio_interrupt(struct sdio_func *func)ks7010_sdio_write (priv,DATA_WINDOW , &rw_data,sizeof (rw_data)); -if (retval) { +if (retval)DPRINTK (1 ,"write DATA_WINDOW Failed!!(%d)\n" , retval); - } status &= ~INT_WRITE_STATUS; }else {#endif @@ -870,13 +860,11 @@ static void ks7010_card_init(struct ks_wlan_private *priv)DPRINTK (5 ,"hostif_sme_enqueu()\n" );if (!wait_for_completion_interruptible_timeout - (&priv->confirm_wait,5 *HZ )) { + (&priv->confirm_wait,5 *HZ ))DPRINTK (1 ,"wait time out!! SME_START\n" ); - } -if (priv->mac_address_valid && priv->version_size) { +if (priv->mac_address_valid && priv->version_size) priv->dev_state =DEVICE_STATE_PREINIT ; - }hostif_sme_enqueue (priv,SME_GET_EEPROM_CKSUM );@@ -898,16 +886,14 @@ static void ks7010_card_init(struct ks_wlan_private *priv)hostif_sme_enqueue (priv,SME_START_REQUEST );if (!wait_for_completion_interruptible_timeout - (&priv->confirm_wait,5 *HZ )) { + (&priv->confirm_wait,5 *HZ ))DPRINTK (1 ,"wait time out!! wireless parameter set\n" ); - }if (priv->dev_state >=DEVICE_STATE_PREINIT ) {DPRINTK (1 ,"DEVICE READY!!\n" ); priv->dev_state =DEVICE_STATE_READY ; - }else { + }else DPRINTK (1 ,"dev_state=%d\n" , priv->dev_state); - } }static void ks7010_init_defaults (struct ks_wlan_private *priv)@@ -1057,9 +1043,8 @@ static int ks7010_sdio_probe(struct sdio_func *func,sdio_claim_host (func); ret =ks7010_sdio_write (priv,INT_PENDING , &rw_data,sizeof (rw_data));sdio_release_host (func); -if (ret) { +if (ret)DPRINTK (1 ," error : INT_PENDING=%02X\n" , rw_data); - }DPRINTK (4 ," clear Interrupt : INT_PENDING=%02X\n" , rw_data);/* enable ks7010sdio interrupt (INT_GCR_B|INT_READ_STATUS|INT_WRITE_STATUS) */ @@ -1067,9 +1052,8 @@ static int ks7010_sdio_probe(struct sdio_func *func,sdio_claim_host (func); ret =ks7010_sdio_write (priv,INT_ENABLE , &rw_data,sizeof (rw_data));sdio_release_host (func); -if (ret) { +if (ret)DPRINTK (1 ," error : INT_ENABLE=%02X\n" , rw_data); - }DPRINTK (4 ," enable Interrupt : INT_ENABLE=%02X\n" , rw_data); priv->dev_state =DEVICE_STATE_BOOT ; --2.9.1
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 5/9] staging: ks7010: Delete unnecessary uses of the variable "retval"
In reply to SF Markus ElfringQuoted 24 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 18:15:23 +0200Some return values can also be directly used for various condition checks. Thus remove a local variable for intermediate assignments.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 81 +++++++++++++++--------------------- 1 file changed, 34 insertions(+), 47 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +0
-1@@ -90,7 +90,6 @@ static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address,void ks_wlan_hw_sleep_doze_request (struct ks_wlan_private *priv) {unsigned char rw_data; -int retval;DPRINTK (4 ,"\n" );
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 104
Quoted 9 lines
drivers/staging/ks7010/ks7010_sdio.c +4
-2@@ -99,9 +98,10 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)if (atomic_read (&priv->sleepstatus.status) =0 ) { rw_data =GCR_B_DOZE ; - retval > -ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {
A multi-line function call in an if test does not look nice at all. The original code was an easy-to-read expectable pattern.
julia
Quoted 185 lines
drivers/staging/ks7010/ks7010_sdio.c +30
-36DPRINTK (1 ," error : GCR_B=%02X\n" , rw_data); goto out; }@@ -121,7 +121,6 @@ out:void ks_wlan_hw_sleep_wakeup_request (struct ks_wlan_private *priv) {unsigned char rw_data; -int retval;DPRINTK (4 ,"\n" );@@ -130,9 +129,10 @@ void ks_wlan_hw_sleep_wakeup_request(struct ks_wlan_private *priv)if (atomic_read (&priv->sleepstatus.status) =1 ) { rw_data =WAKEUP_REQ ; - retval > -ks7010_sdio_write (priv,WAKEUP , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +WAKEUP , + &rw_data, +sizeof (rw_data))) {DPRINTK (1 ," error : WAKEUP=%02X\n" , rw_data); goto out; }@@ -152,16 +152,15 @@ out:void ks_wlan_hw_wakeup_request (struct ks_wlan_private *priv) {unsigned char rw_data; -int retval;DPRINTK (4 ,"\n" );if (atomic_read (&priv->psstatus.status) =PS_SNOOZE ) { rw_data =WAKEUP_REQ ; - retval > -ks7010_sdio_write (priv,WAKEUP , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +WAKEUP , + &rw_data, +sizeof (rw_data)))DPRINTK (1 ," error : WAKEUP=%02X\n" , rw_data); - }DPRINTK (4 ,"wake up : WAKEUP=%02X\n" , rw_data); priv->last_wakeup = jiffies; ++priv->wakeup_count;@@ -175,7 +174,6 @@ int _ks_wlan_hw_power_save(struct ks_wlan_private *priv) {int rc =0 ;unsigned char rw_data; -int retval;if (priv->reg.powermgt =POWMGT_ACTIVE_MODE )return rc;@@ -198,11 +196,11 @@ int _ks_wlan_hw_power_save(struct ks_wlan_private *priv)if (!atomic_read (&priv->psstatus.confirm_wait) && !atomic_read (&priv->psstatus.snooze_guard) && !cnt_txqbody (priv)) { - retval > -ks7010_sdio_read (priv,INT_PENDING , +if (ks7010_sdio_read (priv, +INT_PENDING , &rw_data, -sizeof (rw_data)); -if (retval) { +sizeof (rw_data)) + ) {DPRINTK (1 ," error : INT_PENDING=%02X\n" , rw_data);@@ -212,12 +210,11 @@ int _ks_wlan_hw_power_save(struct ks_wlan_private *priv) }if (!rw_data) { rw_data =GCR_B_DOZE ; - retval > -ks7010_sdio_write (priv, +if (ks7010_sdio_write (priv,GCR_B , &rw_data, -sizeof (rw_data)); -if (retval) { +sizeof (rw_data)) + ) {DPRINTK (1 ," error : GCR_B=%02X\n" , rw_data);@@ -413,7 +410,6 @@ static void rx_event_task(unsigned long dev)static void ks_wlan_hw_rx (void *dev,uint16_t size) {struct ks_wlan_private *priv = (struct ks_wlan_private *)dev; -int retval;struct rx_device_buffer *rx_buffer;struct hostif_hdr *hdr;unsigned char read_status;@@ -429,12 +425,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size) } rx_buffer = &priv->rx_dev.rx_dev_buff[priv->rx_dev.qtail]; - retval > -ks7010_sdio_read (priv,DATA_WINDOW , &rx_buffer->data[0 ], -hif_align_size (size)); -if (retval) { +if (ks7010_sdio_read (priv, +DATA_WINDOW , + &rx_buffer->data[0 ], +hif_align_size (size))) goto error_out; - }/* length check */ if (size >2046 || size =0 ) {@@ -446,12 +441,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)#endif /* rx_status update */ read_status =READ_STATUS_IDLE ; - retval > -ks7010_sdio_write (priv,READ_STATUS , &read_status, -sizeof (read_status)); -if (retval) { +if (ks7010_sdio_write (priv, +READ_STATUS , + &read_status, +sizeof (read_status)))DPRINTK (1 ," error : READ_STATUS=%02X\n" , read_status); - } goto error_out; }@@ -462,12 +456,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)/* read status update */ read_status =READ_STATUS_IDLE ; - retval > -ks7010_sdio_write (priv,READ_STATUS , &read_status, -sizeof (read_status)); -if (retval) { +if (ks7010_sdio_write (priv, +READ_STATUS , + &read_status, +sizeof (read_status)))DPRINTK (1 ," error : READ_STATUS=%02X\n" , read_status); - }DPRINTK (4 ,"READ_STATUS=%02X\n" , read_status);if (atomic_read (&priv->psstatus.confirm_wait)) {@@ -489,7 +482,6 @@ static void ks7010_rw_function(struct work_struct *work)struct hw_info_t *hw;struct ks_wlan_private *priv;unsigned char rw_data; -int retval; hw = container_of(work, struct hw_info_t, rw_wq.work); priv = container_of(hw, struct ks_wlan_private, ks_wlan_hw);@@ -538,9 +530,7 @@ static void ks7010_rw_function(struct work_struct *work) }/* read (WriteStatus/ReadDataSize FN1:00_0014) */ - retval > -ks7010_sdio_read (priv,WSTATUS_RSIZE , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_read (priv,WSTATUS_RSIZE , &rw_data,sizeof (rw_data))) {DPRINTK (1 ," error : WSTATUS_RSIZE=%02X psstatus=%d\n" , rw_data,atomic_read (&priv->psstatus.status)); goto release_host;@@ -708,7 +698,6 @@ static void trx_device_exit(struct ks_wlan_private *priv)static int ks7010_sdio_update_index (struct ks_wlan_private *priv,u32 index) {int rc =0 ; -int retval;unsigned char *data_buf; data_buf =kmalloc (sizeof (u32),GFP_KERNEL );@@ -716,14 +705,12 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)return 1 ;memcpy (data_buf, &index,sizeof (index)); - retval =ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index)); -if (retval) { +if (ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index))) { rc =2 ; goto free_buf; } - retval =ks7010_sdio_write (priv,READ_INDEX , data_buf,sizeof (index)); -if (retval) +if (ks7010_sdio_write (priv,READ_INDEX , data_buf,sizeof (index))) rc =3 ; free_buf:kfree (data_buf); --2.9.1
Re: [PATCH 3/9] staging: ks7010: Return directly after a failed kmalloc()
In reply to SF Markus ElfringQuoted 15 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 15:55:02 +0200Return directly after a memory allocation failed at the beginning.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +0
-0
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) · line 717
Quoted 9 lines
drivers/staging/ks7010/ks7010_sdio.c +2
-4@@ -713,10 +713,8 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)unsigned char *data_buf; data_buf =kmalloc (sizeof (u32),GFP_KERNEL ); -if (!data_buf) { - rc =1 ; - goto error_out; - } +if (!data_buf) +return 1 ;
One could rather wonder why the function has such strange error values...
julia
Quoted 34 lines
drivers/staging/ks7010/ks7010_sdio.c +5
-9memcpy (data_buf, &index,sizeof (index)); retval =ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index));@@ -744,10 +742,9 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,unsigned char *read_buf; read_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL ); -if (!read_buf) { - rc =1 ; - goto error_out; - } +if (!read_buf) +return 1 ; + retval =ks7010_sdio_read (priv, address, read_buf, size);if (retval) { rc =2 ;@@ -777,10 +774,8 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,/* buffer allocate */ rom_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL ); -if (!rom_buf) { - rc =3 ; - goto error_out0; - } +if (!rom_buf) +return 3 ;sdio_claim_host (card->func); --2.9.1
PATCH 1/1 tw686x-kh: Delete an unnecessary check before the function call "video_unregister_device"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 22:00:35 +0200
The video_unregister_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/media/tw686x-kh/tw686x-kh-video.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/media/tw686x-kh/tw686x-kh-video.c +1 -2
@@ -643,8 +643,7 @@ void tw686x_kh_video_free(struct tw686x_dev *dev)struct tw686x_video_channel *vc = &dev->video_channels[ch];v4l2_ctrl_handler_free (&vc->ctrl_handler); -if (vc->device) -video_unregister_device (vc->device); +video_unregister_device (vc->device);vb2_dma_sg_cleanup_ctx (vc->alloc_ctx);for (n =0 ; n <2 ; n++) {struct dma_desc *descs = &vc->sg_tables[n];
Signature · 1 line
2.9.1
Re: [PATCH 7/9] staging: ks7010: Replace three printk() calls by pr_err()
In reply to SF Markus ElfringQuoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 19:12:27 +0200Prefer usage of the macro "
pr_err" over the interface "printk". Fix a typo in an error message.
Please and and use pr_fmt
PATCH 1/1 cec: Delete an unnecessary check before the function call "rc_free_device"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 22:52:49 +0200
The rc_free_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/media/cec/cec-core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/media/cec/cec-core.c +1 -2
@@ -354,8 +354,7 @@ void cec_delete_adapter(struct cec_adapter *adap)if (adap->kthread_config)kthread_stop (adap->kthread_config);#if IS_ENABLED (CONFIG_RC_CORE ) -if (adap->rc) -rc_free_device (adap->rc); +rc_free_device (adap->rc);#endif kfree (adap); }
Signature · 1 line
2.9.1
Re: [PATCH 1/3] xen-scsiback: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 21:21:05 +0200The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Juergen
Re: [PATCH 1/3] xen-scsiback: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 21:21:05 +0200The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 3/3] xen-scsiback: Pass a failure indication as a constant
In reply to SF Markus ElfringQuoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 21:55:01 +0200Pass the constant "FAILED" in a function call directly instead of using an intialisation for a local variable.
Signed-off-by Markus Elfring <[email protected]>
Juergen
Re: [PATCH 3/3] xen-scsiback: Pass a failure indication as a constant
In reply to SF Markus ElfringQuoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 21:55:01 +0200Pass the constant "FAILED" in a function call directly instead of using an intialisation for a local variable.
Signed-off-by Markus Elfring <[email protected]>
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Juergen Gross
maintainerRe: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection
In reply to SF Markus ElfringQuoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 21:42:42 +0200The
kfree()function was called in one case by thescsiback_device_action()function during error handling even if the passed variable "tmr" contained a null pointer.Adjust jump targets according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/xen/xen-scsiback.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/xen/xen-scsiback.c +0
-0
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 610
Quoted 6 lines
drivers/xen/xen-scsiback.c +1
-1@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }
Hmm, I'm not convinced this is an improvement.
I'd rather rename the new error label to "put_cmd" and get rid of the braces in above if statement:
- if (!tmr) {
- target_put_sess_cmd(se_cmd);
- goto err;
- }
+ if (!tmr)
+ goto put_cmd;
and then in the error path:
-err:
+put_cmd:
+ target_put_sess_cmd(se_cmd);
+free_tmr:
kfree(tmr);
Juergen
Quoted 23 lines
drivers/xen/xen-scsiback.c +3
-2init_waitqueue_head (&tmr->tmr_wait);@@ -616,7 +616,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, unpacked_lun, tmr, act,GFP_KERNEL , tag, TARGET_SCF_ACK_KREF);if (rc) - goto err; + goto free_tmr;wait_event (tmr->tmr_wait,atomic_read (&tmr->tmr_complete));@@ -626,8 +626,9 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,scsiback_do_resp_with_sense (NULL , err,0 , pending_req);transport_generic_free_cmd (&pending_req->se_cmd,1 );return ; -err: +free_tmr:kfree (tmr); +do_resp:scsiback_do_resp_with_sense (NULL , err,0 , pending_req); }
Juergen Gross
maintainerRe: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection
In reply to SF Markus ElfringQuoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 21:42:42 +0200The
kfree()function was called in one case by thescsiback_device_action()function during error handling even if the passed variable "tmr" contained a null pointer.Adjust jump targets according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/xen/xen-scsiback.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/xen/xen-scsiback.c +0
-0
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 610
Quoted 6 lines
drivers/xen/xen-scsiback.c +1
-1@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }
Hmm, I'm not convinced this is an improvement.
I'd rather rename the new error label to "put_cmd" and get rid of the braces in above if statement:
- if (!tmr) {
- target_put_sess_cmd(se_cmd);
- goto err;
- }
+ if (!tmr)
+ goto put_cmd;
and then in the error path:
-err:
+put_cmd:
+ target_put_sess_cmd(se_cmd);
+free_tmr:
kfree(tmr);
Juergen
Quoted 13 lines
drivers/xen/xen-scsiback.c +1
-1init_waitqueue_head (&tmr->tmr_wait);@@ -616,7 +616,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, unpacked_lun, tmr, act,GFP_KERNEL , tag, TARGET_SCF_ACK_KREF);if (rc) - goto err; + goto free_tmr;wait_event (tmr->tmr_wait,atomic_read (&tmr->tmr_complete));
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 634
Quoted 10 lines
drivers/xen/xen-scsiback.c +2
-1@@ -626,8 +626,9 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,scsiback_do_resp_with_sense (NULL , err,0 , pending_req);transport_generic_free_cmd (&pending_req->se_cmd,1 );return ; -err: +free_tmr:kfree (tmr); +do_resp:scsiback_do_resp_with_sense (NULL , err,0 , pending_req); }
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH] drm/ast: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 09:54:22 +0200The
drm_gem_object_unreference_unlocked()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Ok, I merged all the non-amd ones from your latest round to drm-misc. Two small nitpicks:
- for cocci patches I prefer if you include the (simplified, if it's a large one) semantic patch in the commit message. Cocci is really badly documented, it's good to see new examples of how.
- threading seems funny in your series. Please generate mail threads using git format-patch --cover-letter $sha1_range and send them out using git send-email. That'll get all the details right. Also pls don't reply with new patches to an old series, that hides the patches and confuses the discussion. Just start a new thread (even when the patches are on the same or similar topic).
Thanks, Daniel
Quoted 26 lines
--- drivers/gpu/drm/ast/ast_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/ast/ast_main.c +1
-2@@ -295,9 +295,8 @@ static int ast_get_dram_info(struct drm_device *dev)static void ast_user_framebuffer_destroy (struct drm_framebuffer *fb) {struct ast_framebuffer *ast_fb =to_ast_framebuffer (fb); -if (ast_fb->obj) -drm_gem_object_unreference_unlocked (ast_fb->obj); +drm_gem_object_unreference_unlocked (ast_fb->obj);drm_framebuffer_cleanup (fb);kfree (fb); }Signature · 6 lines
2.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Martin Schwidefsky
AppliedRe: [PATCH] s390/pci: Delete an unnecessary check before the function call "pci_dev_put"
In reply to SF Markus ElfringQuoted 18 lines · On Sat, 16 Jul 2016 20:40:23 +0200 SF Markus Elfring…
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 20:15:17 +0200The
pci_dev_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- arch/s390/pci/pci_event.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/s390/pci/pci_event.c +0
-0
arch/s390/pci/pci_event.c static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf) · line 151
Quoted 9 lines
arch/s390/pci/pci_event.c +1
-2@@ -145,8 +145,7 @@ static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf)default :break ; } -if (pdev) -pci_dev_put (pdev); +pci_dev_put (pdev); }void zpci_event_availability (void *data)
Applied, thanks.
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
Re: [PATCH] drm/ttm: Delete an unnecessary check before the function call "ttm_tt_destroy"
In reply to SF Markus ElfringQuoted 16 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 15 Jul 2016 20:20:48 +0200The
ttm_tt_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0
drivers/gpu/drm/ttm/ttm_bo.c static void ttm_bo_release_list(struct kref *list_kref) · line 149
Quoted 7 lines
drivers/gpu/drm/ttm/ttm_bo.c +1
-3@@ -146,9 +146,7 @@ static void ttm_bo_release_list(struct kref *list_kref)BUG_ON (bo->mem.mm_node !=NULL );BUG_ON (!list_empty (&bo->lru));BUG_ON (!list_empty (&bo->ddestroy)); - -if (bo->ttm) -ttm_tt_destroy (bo->ttm); +tm_tt_destroy (bo->ttm);
This doesn't compile. Tsk, pls be more careful, and definitely compile-test _all_ your changes before hitting send. I've dropped this one from my queue, the others still look ok.
-Daniel
Quoted 10 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-0atomic_dec (&bo->glob->bo_count);if (bo->resv = &bo->ttm_resv)reservation_object_fini (&bo->ttm_resv);Signature · 6 lines
2.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Christian König
maintainerRe: [PATCH 0/8] drm/amdgpu: Fine-tuning for three function implementations
In reply to SF Markus ElfringAm 16.07.2016 um 16:33 schrieb SF Markus Elfring:
Quoted 5 lines
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 16:23:21 +0200Further update suggestions were taken into account after patches were applied from static source code analysis.
Small coding style nit pick on patch #7:
Review
Quoted 3 lines
(quoted diff) +2
-1- } + } else + temp_storage = NULL;
When an "if" has "{" and "}" the else should also use them even when it is only one line.
With that fixed the whole series is Reviewed-by: Christian König <[email protected]>, but as Walter Harms pointed out as well there are a couple of other things we could make more as well.
Regards,
Christian.
Quoted 16 lines
Markus Elfring (8):
Delete an unnecessary check beforedrm_gem_object_unreference_unlocked()Delete unnecessary checks before the function call "kfree"
One function call less inamdgpu_cgs_acpi_eval_object()after error detection Delete a variable inamdgpu_cgs_acpi_eval_object()
Delete an unnecessary variable initialisation inamdgpu_cgs_acpi_eval_object()Change assignment for a variable inamdgpu_cgs_acpi_eval_object()Change assignment for a buffer variable inphm_dispatch_table()Delete an unnecessary variable initialisation inphm_dispatch_table()drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 28 ++++++++++------------ drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 +--- .../gpu/drm/amd/powerplay/hwmgr/functiontables.c | 12 ++++------ 3 files changed, 19 insertions(+), 25 deletions(-)
Re: [PATCH] drm/hdlcd: Delete an unnecessary check before drm_fbdev_cma_hotplug_event()
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 09:10:40 +0200The
drm_fbdev_cma_hotplug_event()function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Quoted 25 lines
--- drivers/gpu/drm/arm/hdlcd_drv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/arm/hdlcd_drv.c +1
-2@@ -102,8 +102,7 @@ static void hdlcd_fb_output_poll_changed(struct drm_device *drm) {struct hdlcd_drm_private *hdlcd = drm->dev_private; -if (hdlcd->fbdev) -drm_fbdev_cma_hotplug_event (hdlcd->fbdev); +drm_fbdev_cma_hotplug_event (hdlcd->fbdev); }static const struct drm_mode_config_funcs hdlcd_mode_config_funcs = {Signature · 6 lines
2.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 8 lines
==========
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯PATCH v3 1/1 drm/ttm: Delete an unnecessary check before the function call "ttm_tt_destroy"
In reply to Daniel VetterFrom: Markus Elfring <[email protected]>
Date: Mon, 18 Jul 2016 16:06:18 +0200
The ttm_tt_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/ttm/ttm_bo.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +1 -3
@@ -146,9 +146,7 @@ static void ttm_bo_release_list(struct kref *list_kref)BUG_ON (bo->mem.mm_node !=NULL );BUG_ON (!list_empty (&bo->lru));BUG_ON (!list_empty (&bo->ddestroy)); - -if (bo->ttm) -ttm_tt_destroy (bo->ttm); +ttm_tt_destroy (bo->ttm);atomic_dec (&bo->glob->bo_count);if (bo->resv = &bo->ttm_resv)reservation_object_fini (&bo->ttm_resv);
Signature · 1 line
2.9.2
Re: [PATCH v3] drm/ttm: Delete an unnecessary check before the function call "ttm_tt_destroy"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 18 Jul 2016 16:06:18 +0200The
ttm_tt_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
When resending pls describe what changed (and why). Also I'd still like that smatch included in the commit message.
-Daniel
Quoted 22 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +1
-3@@ -146,9 +146,7 @@ static void ttm_bo_release_list(struct kref *list_kref)BUG_ON (bo->mem.mm_node !=NULL );BUG_ON (!list_empty (&bo->lru));BUG_ON (!list_empty (&bo->ddestroy)); - -if (bo->ttm) -ttm_tt_destroy (bo->ttm); +ttm_tt_destroy (bo->ttm);atomic_dec (&bo->glob->bo_count);if (bo->resv = &bo->ttm_resv)reservation_object_fini (&bo->ttm_resv);Signature · 1 line
2.9.2
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: drm/ttm: Delete an unnecessary check before the function call "ttm_tt_destroy"
Quoted 1 line
When resending pls describe what changed (and why).
v3: A bit of reformatting with current software
v2: Broken patch where I managed to delete a "t" too much in a source code
line somehow.
v1: See also a similar update suggestion
https://lkml.org/lkml/2015/11/16/416
Would you like to pick such a software adjustment up?
Regards,
Markus
PATCH 1/1 hwmon-ntc_thermistor: Delete an unnecessary check before the function call "iio_channel_release"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 18 Jul 2016 20:34:41 +0200
The iio_channel_release() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/hwmon/ntc_thermistor.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/hwmon/ntc_thermistor.c +1 -2
@@ -361,8 +361,7 @@ ntc_thermistor_parse_dt(struct platform_device *pdev) }static void ntc_iio_channel_release (struct ntc_thermistor_platform_data *pdata) { -if (pdata->chan) -iio_channel_release (pdata->chan); +iio_channel_release (pdata->chan); }#else static struct ntc_thermistor_platform_data *
Signature · 1 line
2.9.2
PATCH 1/1 virtio-balloon: Delete an unnecessary check before the function call "iput"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 18 Jul 2016 21:17:18 +0200
The iput() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/virtio/virtio_balloon.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/virtio/virtio_balloon.c +1 -2
@@ -611,8 +611,7 @@ static void virtballoon_remove(struct virtio_device *vdev)cancel_work_sync (&vb->update_balloon_stats_work);remove_common (vb); -if (vb->vb_dev_info.inode) -iput (vb->vb_dev_info.inode); +iput (vb->vb_dev_info.inode);kfree (vb); }
Signature · 1 line
2.9.2
PATCH 1/1 virtio-balloon: Delete an unnecessary check before the function call "iput"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 18 Jul 2016 21:17:18 +0200
The iput() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/virtio/virtio_balloon.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/virtio/virtio_balloon.c +1 -2
@@ -611,8 +611,7 @@ static void virtballoon_remove(struct virtio_device *vdev)cancel_work_sync (&vb->update_balloon_stats_work);remove_common (vb); -if (vb->vb_dev_info.inode) -iput (vb->vb_dev_info.inode); +iput (vb->vb_dev_info.inode);kfree (vb); }
Signature · 1 line
2.9.2
Re: [PATCH] IPC-mqueue: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringQuoted 30 lines
From: Markus Elfring <[email protected]>
Date: Thu, 5 Nov 2015 17:55:25 +0100The functions
iput()andunregister_sysctl_table()test whether their argument is NULL and then return immediately.
Thus the tests around their calls are not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- ipc/mqueue.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)ipc/mqueue.c +1
-2@@ -885,8 +885,7 @@ SYSCALL_DEFINE1(mq_unlink, const char __user *, u_name) out_unlock:mutex_unlock (&d_inode (mnt->mnt_root)->i_mutex); -if (inode) -iput (inode); +iput (inode);mnt_drop_write (mnt); out_name:putname (name);
ipc/mqueue.c static int __init init_mqueue_fs(void) · line 1465
Quoted 9 lines
ipc/mqueue.c +1
-2@@ -1460,8 +1459,7 @@ static int __init init_mqueue_fs(void) out_filesystem:unregister_filesystem (&mqueue_fs_type); out_sysctl: -if (mq_sysctl_table) -unregister_sysctl_table (mq_sysctl_table); +unregister_sysctl_table (mq_sysctl_table);kmem_cache_destroy (mqueue_inode_cachep);return error; }
How do you think about to integrate this update suggestion into another source code repository?
Regards,
Markus
Re: [PATCH] drm/rockchip: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
In reply to SF Markus ElfringQuoted 23 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 15 Jul 2016 15:23:22 +0200The
drm_gem_object_unreference_unlocked()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)drivers/gpu/drm/rockchip/rockchip_drm_fb.c +0
-1@@ -43,14 +43,10 @@ struct drm_gem_object *rockchip_fb_get_gem_obj(struct drm_framebuffer *fb,static void rockchip_drm_fb_destroy (struct drm_framebuffer *fb) {struct rockchip_drm_fb *rockchip_fb =to_rockchip_fb (fb); -struct drm_gem_object *obj;
drivers/gpu/drm/rockchip/rockchip_drm_fb.c struct drm_gem_object *rockchip_fb_get_gem_obj(struct drm_framebuffer *fb, · line 50
Quoted 10 lines
drivers/gpu/drm/rockchip/rockchip_drm_fb.c +2
-5int i; -for (i =0 ; i <ROCKCHIP_MAX_FB_BUFFER ; i++) { - obj = rockchip_fb->obj[i]; -if (obj) -drm_gem_object_unreference_unlocked (obj); - } +for (i =0 ; i <ROCKCHIP_MAX_FB_BUFFER ; i++) +drm_gem_object_unreference_unlocked (rockchip_fb->obj[i]);
Good, Thanks for the fixes, Applied to my drm-fixes.
Quoted 2 lines
drivers/gpu/drm/rockchip/rockchip_drm_fb.c +0
-0drm_framebuffer_cleanup (fb);kfree (rockchip_fb);
Signature · 1 line
Mark Yao
Guenter Roeck
maintainerRe: [PATCH] hwmon-ntc_thermistor: Delete an unnecessary check before the function call "iio_channel_release"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 18 Jul 2016 20:34:41 +0200The
iio_channel_release()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
A much better change would be to use devm_iio_channel_get() instead of iio_channel_get(), and to remove ntc_iio_channel_release() completely.
Guenter
Geert Uytterhoeven
Reviewed-by Alex DeucherRe: [PATCH v3] drm/ttm: Delete an unnecessary check before the function call "ttm_tt_destroy"
In reply to Daniel VetterQuoted 7 lines · Daniel Vetter
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 18 Jul 2016 16:06:18 +0200The
ttm_tt_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
Quoted 6 lines
Quoted 3 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>When resending pls describe what changed (and why). Also I'd still like that smatch included in the commit message.
A similar change was made in drm-next, causing a merge conflict between the drm-next and drm-misc trees.
commit 4279cb1423d96e53b6b98ae9f2b41003b013a31f
Author: Christian König <[email protected]> Date: Mon Jun 6 10:17:51 2016 +0200
drm/ttm: remove NULL checks when calling ttm_tt_destroy
The function is a no-op with a NULL pointer.
Signature · 10 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus TorvaldsRe: [PATCH v3] drm/ttm: Delete an unnecessary check before the function call "ttm_tt_destroy"
Quoted 22 lines · Geert Uytterhoeven
Quoted 7 lines · Daniel Vetter
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Mon, 18 Jul 2016 16:06:18 +0200The
ttm_tt_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.Quoted 6 lines
Quoted 3 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>When resending pls describe what changed (and why). Also I'd still like that smatch included in the commit message.
A similar change was made in drm-next, causing a merge conflict between the drm-next and drm-misc trees.
commit
4279cb1423d96e53b6b98ae9f2b41003b013a31fAuthor: Christian König <[email protected]> Date: Mon Jun 6 10:17:51 2016 +0200
Quoted 7 lines
drm/ttm: remove NULL checks when calling
ttm_tt_destroyThe function is a no-op with a NULL pointer.
Reviewed-by Alex Deucher <[email protected]>Signed-off-by Christian König <[email protected]>Signed-off-by Alex Deucher <[email protected]>
Yeah, realized that too but then drm-misc is a non-rebasing tree now, so can't take this out.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection
In reply to Juergen GrossQuoted 22 lines
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 610
Quoted 7 lines
drivers/xen/xen-scsiback.c +1
-1@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }Hmm, I'm not convinced this is an improvement.
I'd rather rename the new error label to "
put_cmd" and get rid of the braces in above if statement:(quoted diff) +2
-4- if (!tmr) { - target_put_sess_cmd(se_cmd); - goto err; - } + if (!tmr) + goto put_cmd;and then in the error path:
Review
Quoted 3 lines
(quoted diff) +2
-1-err: +put_cmd: + target_put_sess_cmd(se_cmd);
I am unsure on the relevance of this function on such a source position. Would it make sense to move it further down at the end?
Quoted 2 lines
+free_tmr:
kfree(tmr);
How do you think about to skip this function call after a memory allocation failure?
Regards,
Markus
Re: [PATCH] sh-DWARF: Delete unnecessary checks before the function call "mempool_destroy"
In reply to SF Markus ElfringQuoted 21 lines
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 08:20:36 +0100The
mempool_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- arch/sh/kernel/dwarf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)arch/sh/kernel/dwarf.c +0
-0@@ -1009,10 +1009,8 @@ static void __init dwarf_unwinder_cleanup(void)rbtree_postorder_for_each_entry_safe (cie, next_cie, &cie_root, node)kfree (cie);
arch/sh/kernel/dwarf.c static void __init dwarf_unwinder_cleanup(void) · line 1016
Quoted 10 lines
arch/sh/kernel/dwarf.c +2
-4-if (dwarf_reg_pool) -mempool_destroy (dwarf_reg_pool); -if (dwarf_frame_pool) -mempool_destroy (dwarf_frame_pool); +mempool_destroy (dwarf_reg_pool); +mempool_destroy (dwarf_frame_pool);kmem_cache_destroy (dwarf_reg_cachep);kmem_cache_destroy (dwarf_frame_cachep); }
How do you think about to integrate this update suggestion into another source code repository?
Regards,
Markus
PATCH 1/1 v4l2-common: Delete an unnecessary check before the function call "spi_unregister_device"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 19 Jul 2016 19:54:16 +0200
The spi_unregister_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/media/v4l2-core/v4l2-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-common.c +1 -1
@@ -291,7 +291,7 @@ struct v4l2_subdev *v4l2_spi_new_subdev(struct v4l2_device *v4l2_dev, error:/* If we have a client but no subdev, then something went wrong and we must unregister the client. */ -if (spi && sd =NULL ) +if (!sd)spi_unregister_device (spi);return sd;
Signature · 1 line
2.9.2
Re: [PATCH] drm/arcpgu: Delete an unnecessary check before drm_fbdev_cma_hotplug_event()
In reply to SF Markus ElfringHi Markus,
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 15 Jul 2016 21:52:40 +-0200The
drm_fbdev_cma_hotplug_event()function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Good catch!
Re: [PATCH] [media] v4l2-common: Delete an unnecessary check before the function call "spi_unregister_device"
In reply to SF Markus ElfringAm 19.07.2016 20:02, schrieb SF Markus Elfring:
Quoted 18 lines
From: Markus Elfring <[email protected]>
Date: Tue, 19 Jul 2016 19:54:16 +0200The
spi_unregister_device()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/media/v4l2-core/v4l2-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/v4l2-core/v4l2-common.c +0
-0
drivers/media/v4l2-core/v4l2-common.c struct v4l2_subdev *v4l2_spi_new_subdev(struct v4l2_device *v4l2_dev, · line 297
Quoted 8 lines
drivers/media/v4l2-core/v4l2-common.c +1
-1@@ -291,7 +291,7 @@ struct v4l2_subdev *v4l2_spi_new_subdev(struct v4l2_device *v4l2_dev, error:/* If we have a client but no subdev, then something went wrong and we must unregister the client. */ -if (spi && sd =NULL ) +if (!sd)spi_unregister_device (spi);return sd;
if i read the code correct sd is always NULL at this point. so this was wrong in the first place and you must remove sd also.
re,
wh
Re: [PATCH] sh-DWARF: Delete unnecessary checks before the function call "mempool_destroy"
In reply to SF Markus ElfringQuoted 21 lines · SF Markus Elfring
Quoted 21 lines
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 08:20:36 +0100The
mempool_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- arch/sh/kernel/dwarf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)arch/sh/kernel/dwarf.c +0
-0@@ -1009,10 +1009,8 @@ static void __init dwarf_unwinder_cleanup(void)rbtree_postorder_for_each_entry_safe (cie, next_cie, &cie_root, node)kfree (cie);
Quoted 14 lines
arch/sh/kernel/dwarf.c static void __init dwarf_unwinder_cleanup(void) · line 1016
Quoted 10 lines
arch/sh/kernel/dwarf.c +2
-4-if (dwarf_reg_pool) -mempool_destroy (dwarf_reg_pool); -if (dwarf_frame_pool) -mempool_destroy (dwarf_frame_pool); +mempool_destroy (dwarf_reg_pool); +mempool_destroy (dwarf_frame_pool);kmem_cache_destroy (dwarf_reg_cachep);kmem_cache_destroy (dwarf_frame_cachep); }How do you think about to integrate this update suggestion into another source code repository?
Your patch is fine, but you may want to send it to the maintainers directly to merge.
$ ./scripts/get_maintainer.pl -f arch/sh/kernel/dwarf.c Yoshinori Sato <[email protected]> (maintainer:SUPERH) Rich Felker <[email protected]> (maintainer:SUPERH) [email protected] (open list:SUPERH) [email protected] (open list)
PATCH 1/1 tw686x: Delete an unnecessary check before the function call "video_unregister_device"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 19 Jul 2016 21:24:26 +0200
The video_unregister_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/media/pci/tw686x/tw686x-video.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/pci/tw686x/tw686x-video.c +1 -2
@@ -1093,8 +1093,7 @@ void tw686x_video_free(struct tw686x_dev *dev)for (ch =0 ; ch <max_channels (dev); ch++) {struct tw686x_video_channel *vc = &dev->video_channels[ch]; -if (vc->device) -video_unregister_device (vc->device); +video_unregister_device (vc->device);if (dev->dma_ops->free)for (pb =0 ; pb <2 ; pb++)
Signature · 1 line
2.9.2
Re: [PATCH] WiMAX-i2400m: Delete an unnecessary check before the function call "kfree_skb"
In reply to SF Markus ElfringQuoted 19 lines
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 11:17:55 +0100The
kfree_skb()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/net/wimax/i2400m/control.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/wimax/i2400m/control.c +0
-0
drivers/net/wimax/i2400m/control.c void i2400m_msg_to_dev_cancel_wait(struct i2400m *i2400m, int code) · line 650
Quoted 8 lines
drivers/net/wimax/i2400m/control.c +1
-1@@ -644,7 +644,7 @@ void i2400m_msg_to_dev_cancel_wait(struct i2400m *i2400m, int code)spin_lock_irqsave (&i2400m->rx_lock, flags); ack_skb = i2400m->ack_skb; -if (ack_skb && !IS_ERR (ack_skb)) +if (!IS_ERR (ack_skb))kfree_skb (ack_skb); i2400m->ack_skb =ERR_PTR (code);spin_unlock_irqrestore (&i2400m->rx_lock, flags);
How do you think about to integrate this update suggestion into another source code repository?
Regards,
Markus
PATCH 1/1 of: Delete an unnecessary check before the function call "of_node_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 19 Jul 2016 22:42:22 +0200
The of_node_put() function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/of/base.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/of/base.c +1 -2
@@ -1609,8 +1609,7 @@ static int __of_parse_phandle_with_args(const struct device_node *np,*/ err: -if (it.node) -of_node_put (it.node); +of_node_put (it.node);return rc; }
Signature · 1 line
2.9.2
Re: [PATCH] sh-DWARF: Delete unnecessary checks before the function call "mempool_destroy"
In reply to SF Markus ElfringQuoted 21 lines
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 08:20:36 +0100The
mempool_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- arch/sh/kernel/dwarf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)arch/sh/kernel/dwarf.c +0
-0@@ -1009,10 +1009,8 @@ static void __init dwarf_unwinder_cleanup(void)rbtree_postorder_for_each_entry_safe (cie, next_cie, &cie_root, node)kfree (cie);
arch/sh/kernel/dwarf.c static void __init dwarf_unwinder_cleanup(void) · line 1016
Quoted 10 lines
arch/sh/kernel/dwarf.c +2
-4-if (dwarf_reg_pool) -mempool_destroy (dwarf_reg_pool); -if (dwarf_frame_pool) -mempool_destroy (dwarf_frame_pool); +mempool_destroy (dwarf_reg_pool); +mempool_destroy (dwarf_frame_pool);kmem_cache_destroy (dwarf_reg_cachep);kmem_cache_destroy (dwarf_frame_cachep); }
Would you like to integrate this update suggestion into another source code repository?
Regards,
Markus
Juergen Gross
maintainerRe: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection
In reply to SF Markus ElfringQuoted 20 lines · SF Markus Elfring
Quoted 20 lines
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 610
Quoted 7 lines
drivers/xen/xen-scsiback.c +1
-1@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }Hmm, I'm not convinced this is an improvement.
I'd rather rename the new error label to "
put_cmd" and get rid of the braces in above if statement:(quoted diff) +2
-4- if (!tmr) { - target_put_sess_cmd(se_cmd); - goto err; - } + if (!tmr) + goto put_cmd;
Quoted 8 lines
Review
Quoted 5 lines
and then in the error path:
(quoted diff) +2
-1-err: +put_cmd: + target_put_sess_cmd(se_cmd);I am unsure on the relevance of this function on such a source position. Would it make sense to move it further down at the end?
You only want to call it in the first error case (allocation failure).
Quoted 5 lines
Quoted 2 lines
+free_tmr:
kfree(tmr);How do you think about to skip this function call after a memory allocation failure?
I think this just doesn't matter. If it were a hot path, yes. But trying to do micro-optimizations in an error path is just not worth the effort.
I like a linear error path containing all the needed cleanups best.
Juergen
Juergen Gross
maintainerRe: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection
In reply to SF Markus ElfringQuoted 20 lines · SF Markus Elfring
Quoted 20 lines
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 610
Quoted 7 lines
drivers/xen/xen-scsiback.c +1
-1@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }Hmm, I'm not convinced this is an improvement.
I'd rather rename the new error label to "
put_cmd" and get rid of the braces in above if statement:(quoted diff) +2
-4- if (!tmr) { - target_put_sess_cmd(se_cmd); - goto err; - } + if (!tmr) + goto put_cmd;
Quoted 8 lines
Review
Quoted 5 lines
and then in the error path:
(quoted diff) +2
-1-err: +put_cmd: + target_put_sess_cmd(se_cmd);I am unsure on the relevance of this function on such a source position. Would it make sense to move it further down at the end?
You only want to call it in the first error case (allocation failure).
Quoted 5 lines
Quoted 2 lines
+free_tmr:
kfree(tmr);How do you think about to skip this function call after a memory allocation failure?
I think this just doesn't matter. If it were a hot path, yes. But trying to do micro-optimizations in an error path is just not worth the effort.
I like a linear error path containing all the needed cleanups best.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection
In reply to Juergen GrossQuoted 22 lines
Quoted 22 lines
Quoted 22 lines
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 610
Quoted 7 lines
drivers/xen/xen-scsiback.c +1
-1@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }Hmm, I'm not convinced this is an improvement.
I'd rather rename the new error label to "
put_cmd" and get rid of the braces in above if statement:(quoted diff) +2
-4- if (!tmr) { - target_put_sess_cmd(se_cmd); - goto err; - } + if (!tmr) + goto put_cmd;and then in the error path:
Quoted 8 lines
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +2
-1-err: +put_cmd: + target_put_sess_cmd(se_cmd);I am unsure on the relevance of this function on such a source position. Would it make sense to move it further down at the end?
You only want to call it in the first error case (allocation failure).
Thanks for your clarification.
I find that my update suggestion (from Saturday) is still appropriate in this case.
https://lkml.org/lkml/2016/7/16/172
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
+free_tmr:
kfree(tmr);How do you think about to skip this function call after a memory allocation failure?
I think this just doesn't matter. If it were a hot path, yes. But trying to do micro-optimizations in an error path is just not worth the effort.
Would you like to reduce also the amount of function calls in such special run-time situations?
Quoted 1 line
I like a linear error path containing all the needed cleanups best.
I would prefer to keep the discussed single function call within the basic block of the if statement.
Have we got different opinions about the shown implementation details?
Regards,
Markus
Juergen Gross
maintainerRe: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection
Quoted 29 lines · SF Markus Elfring
Quoted 29 lines
Quoted 28 lines
Quoted 22 lines
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 610
Quoted 7 lines
drivers/xen/xen-scsiback.c +1
-1@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }Hmm, I'm not convinced this is an improvement.
I'd rather rename the new error label to "
put_cmd" and get rid of the braces in above if statement:(quoted diff) +2
-4- if (!tmr) { - target_put_sess_cmd(se_cmd); - goto err; - } + if (!tmr) + goto put_cmd;and then in the error path:
Review
Quoted 3 lines
(quoted diff) +2
-1-err: +put_cmd: + target_put_sess_cmd(se_cmd);I am unsure on the relevance of this function on such a source position. Would it make sense to move it further down at the end?
Quoted 7 lines
Quoted 1 line
You only want to call it in the first error case (allocation failure).
Thanks for your clarification.
I find that my update suggestion (from Saturday) is still appropriate in this case.
https://lkml.org/lkml/2016/7/16/172
And I still think it isn't an improvement: Nack
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
+free_tmr:
kfree(tmr);How do you think about to skip this function call after a memory allocation failure?
I think this just doesn't matter. If it were a hot path, yes. But trying to do micro-optimizations in an error path is just not worth the effort.
Would you like to reduce also the amount of function calls in such special run-time situations?
I just don't care for the extra 2 or 3 nsecs. Readability is more important here.
Quoted 6 lines
Quoted 1 line
I like a linear error path containing all the needed cleanups best.
I would prefer to keep the discussed single function call within the basic block of the if statement.
Have we got different opinions about the shown implementation details?
Yes.
Juergen
Juergen Gross
maintainerRe: [PATCH 2/3] xen-scsiback: One function call less in scsiback_device_action() after error detection
In reply to SF Markus ElfringQuoted 29 lines · SF Markus Elfring
Quoted 29 lines
Quoted 28 lines
Quoted 22 lines
drivers/xen/xen-scsiback.c static void scsiback_device_action(struct vscsibk_pend *pending_req, · line 610
Quoted 7 lines
drivers/xen/xen-scsiback.c +1
-1@@ -606,7 +606,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr) {target_put_sess_cmd (se_cmd); - goto err; + goto do_resp; }Hmm, I'm not convinced this is an improvement.
I'd rather rename the new error label to "
put_cmd" and get rid of the braces in above if statement:(quoted diff) +2
-4- if (!tmr) { - target_put_sess_cmd(se_cmd); - goto err; - } + if (!tmr) + goto put_cmd;and then in the error path:
Review
Quoted 3 lines
(quoted diff) +2
-1-err: +put_cmd: + target_put_sess_cmd(se_cmd);I am unsure on the relevance of this function on such a source position. Would it make sense to move it further down at the end?
Quoted 7 lines
Quoted 1 line
You only want to call it in the first error case (allocation failure).
Thanks for your clarification.
I find that my update suggestion (from Saturday) is still appropriate in this case.
https://lkml.org/lkml/2016/7/16/172
And I still think it isn't an improvement: Nack
Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
+free_tmr:
kfree(tmr);How do you think about to skip this function call after a memory allocation failure?
I think this just doesn't matter. If it were a hot path, yes. But trying to do micro-optimizations in an error path is just not worth the effort.
Would you like to reduce also the amount of function calls in such special run-time situations?
I just don't care for the extra 2 or 3 nsecs. Readability is more important here.
Quoted 6 lines
Quoted 1 line
I like a linear error path containing all the needed cleanups best.
I would prefer to keep the discussed single function call within the basic block of the if statement.
Have we got different opinions about the shown implementation details?
Yes.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
v2 cover xen-scsiback: Fine-tuning for scsiback_device_action()
In reply to Juergen GrossFrom: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 13:20:04 +0200
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (3):
Delete an unnecessary check before the function call "kfree" Rename jump labels in scsiback_device_action() Pass a failure indication as a constant
drivers/xen/xen-scsiback.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
Signature · 1 line
2.9.2
PATCH v2 1/3 xen-scsiback: Delete an unnecessary check before the function call "kfree"
From: Markus Elfring <[email protected]>
Date: Tue, 19 Jul 2016 15:42:19 +0200
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
---
v2: Rebased on source files from "Linux next-20160719"
drivers/xen/xen-scsiback.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/xen/xen-scsiback.c +1 -2
@@ -627,8 +627,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,transport_generic_free_cmd (&pending_req->se_cmd,1 );return ; err: -if (tmr) -kfree (tmr); +kfree (tmr);scsiback_do_resp_with_sense (NULL , err,0 , pending_req); }
Signature · 1 line
2.9.2
PATCH v2 2/3 xen-scsiback: Rename jump labels in scsiback_device_action()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 13:03:16 +0200
* Adjust jump targets according to the Linux coding style convention.
* A bit of refactoring for the control flow
---
v2: Rebased on source files from "Linux next-20160719"
Changes from a bit of code review
drivers/xen/xen-scsiback.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/xen/xen-scsiback.c +6 -6
@@ -604,10 +604,8 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,int rc, err =FAILED ; tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL ); -if (!tmr) { -target_put_sess_cmd (se_cmd); - goto err; - } +if (!tmr) + goto put_cmd;init_waitqueue_head (&tmr->tmr_wait);
@@ -616,7 +614,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req, unpacked_lun, tmr, act,GFP_KERNEL , tag, TARGET_SCF_ACK_KREF);if (rc) - goto err; + goto free_tmr;wait_event (tmr->tmr_wait,atomic_read (&tmr->tmr_complete));
@@ -626,7 +624,9 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,scsiback_do_resp_with_sense (NULL , err,0 , pending_req);transport_generic_free_cmd (&pending_req->se_cmd,1 );return ; -err: +put_cmd: +target_put_sess_cmd (se_cmd); +free_tmr:kfree (tmr);scsiback_do_resp_with_sense (NULL , err,0 , pending_req); }
Signature · 6 lines
2.9.2 -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 3/3 xen-scsiback: Pass a failure indication as a constant
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 13:12:33 +0200
Pass the constant "FAILED" in a function call directly instead of using an intialisation for a local variable.
---
v2: Rebased on source files from "Linux next-20160719"
drivers/xen/xen-scsiback.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/xen-scsiback.c +2 -2
@@ -601,7 +601,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,struct se_cmd *se_cmd = &pending_req->se_cmd;struct scsiback_tmr *tmr;u64 unpacked_lun = pending_req->v2p->lun; -int rc, err =FAILED ; +int rc, err; tmr =kzalloc (sizeof (struct scsiback_tmr ),GFP_KERNEL );if (!tmr)
@@ -628,7 +628,7 @@ put_cmd:target_put_sess_cmd (se_cmd); free_tmr:kfree (tmr); -scsiback_do_resp_with_sense (NULL , err,0 , pending_req); +scsiback_do_resp_with_sense (NULL ,FAILED ,0 , pending_req); }/*
Signature · 1 line
2.9.2
Re: [PATCH v2 1/3] xen-scsiback: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 19 Jul 2016 15:42:19 +0200The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Even if already given, here it is again:
Juergen
Re: [PATCH v2 1/3] xen-scsiback: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 19 Jul 2016 15:42:19 +0200The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Even if already given, here it is again:
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 3/3] xen-scsiback: Pass a failure indication as a constant
In reply to SF Markus ElfringQuoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 13:12:33 +0200Pass the constant "FAILED" in a function call directly instead of using an intialisation for a local variable.
Signed-off-by Markus Elfring <[email protected]>
Even if already given, here it is again:
Juergen
Re: [PATCH v2 3/3] xen-scsiback: Pass a failure indication as a constant
In reply to SF Markus ElfringQuoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 13:12:33 +0200Pass the constant "FAILED" in a function call directly instead of using an intialisation for a local variable.
Signed-off-by Markus Elfring <[email protected]>
Even if already given, here it is again:
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 2/3] xen-scsiback: Rename jump labels in scsiback_device_action()
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 13:03:16 +0200* Adjust jump targets according to the Linux coding style convention.
* A bit of refactoring for the control flow
Suggested-by Jürgen Groß <[email protected]>Signed-off-by Markus Elfring <[email protected]>
Juergen
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 2/3] xen-scsiback: Rename jump labels in scsiback_device_action()
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 13:03:16 +0200* Adjust jump targets according to the Linux coding style convention.
* A bit of refactoring for the control flow
Suggested-by Jürgen Groß <[email protected]>Signed-off-by Markus Elfring <[email protected]>
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH] SRAM: Delete an unnecessary check before the function call "of_node_put"
In reply to SF Markus ElfringQuoted 19 lines
From: Markus Elfring <[email protected]>
Date: Fri, 6 Nov 2015 10:36:49 +0100The
of_node_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/misc/sram.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/misc/sram.c +0
-0
drivers/misc/sram.c static int sram_reserve_regions(struct sram_dev *sram, struct resource *res) · line 332
Quoted 10 lines
drivers/misc/sram.c +1
-3@@ -326,9 +326,7 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res) } err_chunks: -if (child) -of_node_put (child); - +of_node_put (child);kfree (rblocks);return ret;
How do you think about to integrate this update suggestion into another source code repository?
Regards,
Markus
PATCH 1/1 cxl: Delete an unnecessary check before the function call "of_node_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 15:10:32 +0200
The of_node_put() function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/misc/cxl/of.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/misc/cxl/of.c +1 -2
@@ -490,8 +490,7 @@ int cxl_of_probe(struct platform_device *pdev) adapter->slices =0 ; } -if (afu_np) -of_node_put (afu_np); +of_node_put (afu_np);return 0 ; }
Signature · 1 line
2.9.2
Re: [PATCH] cxl: Delete an unnecessary check before the function call "of_node_put"
Quoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 15:10:32 +0200The
of_node_put()function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/misc/cxl/of.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/misc/cxl/of.c +0
-0
drivers/misc/cxl/of.c int cxl_of_probe(struct platform_device *pdev) · line 495
Quoted 8 lines
drivers/misc/cxl/of.c +1
-2@@ -490,8 +490,7 @@ int cxl_of_probe(struct platform_device *pdev) adapter->slices =0 ; } -if (afu_np) -of_node_put (afu_np); +of_node_put (afu_np);return 0 ; }
I don't think that the call should be there at all. The loop only exits when afu_np is NULL. Furthermore, the loop should not be written as a for loop, but rather with for_each_child_of_node.
julia
Re: [PATCH 1/9] staging: ks7010: Delete unnecessary checks before the function call "kfree"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 13:14:57 +0200The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Re: [PATCH 2/9] staging: ks7010: Delete unnecessary assignments for buffer variables
In reply to SF Markus ElfringQuoted 8 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 13:38:46 +0200A few variables were assigned a null pointer despite of the detail that they were immediately reassigned by the following statement. Thus remove such unnecessary assignments.
Signed-off-by Markus Elfring <[email protected]>
Re: [PATCH 3/9] staging: ks7010: Return directly after a failed kmalloc()
In reply to Julia LawallQuoted 21 lines · Julia Lawall
Quoted 17 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 15:55:02 +0200Return directly after a memory allocation failed at the beginning.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +0
-0@@ -713,10 +713,8 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)unsigned char *data_buf;
Quoted 9 lines
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) · line 717
Quoted 7 lines
drivers/staging/ks7010/ks7010_sdio.c +2
-4data_buf =kmalloc (sizeof (u32),GFP_KERNEL ); -if (!data_buf) { - rc =1 ; - goto error_out; - } +if (!data_buf) +return 1 ;One could rather wonder why the function has such strange error values...
Agreed. Markus, can you check if we can use -ENOMEM in those places.
Re: [PATCH 4/9] staging: ks7010: Rename jump labels
In reply to SF Markus ElfringQuoted 4 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 16:26:18 +0200Adjust jump targets according to the Linux coding style convention.
Really? Is that documented somewhere?
Quoting Jean Delvare:
"> It is generally accepted to indent labels with a single space. This
Quoted 1 line
avoids breaking the -p option of diff."
So, NACK for now unless we know 'diff' has been fixed.
Re: [PATCH 5/9] staging: ks7010: Delete unnecessary uses of the variable "retval"
In reply to Julia LawallQuoted 29 lines · Julia Lawall
Quoted 25 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 18:15:23 +0200Some return values can also be directly used for various condition checks. Thus remove a local variable for intermediate assignments.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 81 +++++++++++++++--------------------- 1 file changed, 34 insertions(+), 47 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +0
-1@@ -90,7 +90,6 @@ static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address,void ks_wlan_hw_sleep_doze_request (struct ks_wlan_private *priv) {unsigned char rw_data; -int retval;DPRINTK (4 ,"\n" );@@ -99,9 +98,10 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)
Quoted 12 lines
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 104
Quoted 9 lines
drivers/staging/ks7010/ks7010_sdio.c +4
-3if (atomic_read (&priv->sleepstatus.status) ==0 ) { rw_data =GCR_B_DOZE ; - retval = -ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {A multi-line function call in an if test does not look nice at all. The original code was an easy-to-read expectable pattern.
I agree. I am not strict on the 80 char limit, especially in cases like the above.
Re: [PATCH 6/9] staging: ks7010: Delete unnecessary braces
In reply to Julia LawallQuoted 15 lines · Julia Lawall
Quoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 18:39:03 +0200Do not use curly brackets at some source code places where a single statement should be sufficient.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 48 ++++++++++++------------------------ 1 file changed, 16 insertions(+), 32 deletions(-)
Quoted 14 lines
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 114
Quoted 12 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-2@@ -109,9 +109,8 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)DPRINTK (3 ,"sleep_mode=SLP_SLEEP\n" );atomic_set (&priv->sleepstatus.status,1 ); priv->last_doze = jiffies; - }else { + }else DPRINTK (1 ,"sleep_mode=%d\n" , priv->sleep_mode); - }This is a violation of CodingStyle:
Julia is right again, I agree.
Re: [PATCH 7/9] staging: ks7010: Replace three printk() calls by pr_err()
In reply to Joe PerchesQuoted 8 lines · Joe Perches
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 19:12:27 +0200Prefer usage of the macro "
pr_err" over the interface "printk". Fix a typo in an error message.Please and and use
pr_fmt
Can't we use dev_* on the SDIO device?
Re: [PATCH 8/9] staging: ks7010: Delete a variable in write_to_device()
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From
01291121668ccb54f1a784765a8d2b5811afa75aMon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 19:26:15 +0200
Subject: [PATCH 8/9] staging: ks7010: Delete a variable inwrite_to_device()The local variable "rc" was assigned a zero at one place. But it was not read within this function. Thus delete it.
Signed-off-by Markus Elfring <[email protected]>
Re: [PATCH 9/9] staging: ks7010: Delete three unnecessary variable initialisations
In reply to Julia LawallQuoted 25 lines · Julia Lawall
Quoted 21 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 17 Jul 2016 19:40:47 +0200Three variables will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +0
-1@@ -323,14 +323,14 @@ static void tx_device_task(void *dev) {struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;struct tx_device_buffer *sp; -int rc =0 ;
Quoted 13 lines
drivers/staging/ks7010/ks7010_sdio.c static void tx_device_task(void *dev) · line 332
Quoted 7 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-1DPRINTK (4 ,"\n" );if (cnt_txqbody (priv) >0 &&atomic_read (&priv->psstatus.status) !=PS_SNOOZE ) { sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead];if (priv->dev_state >=DEVICE_STATE_BOOT ) { - rc =write_to_device (priv, sp->sendp, sp->size); +int rc =write_to_device (priv, sp->sendp, sp->size);This does not look appealing to me, neither the declaration in the middle of the function, nor the intiialization to the result of a complex expression, nor the separation of the call and the error checking code by a blank line. There is nothing wrong with having the rc variable be declared at the the top of the function, in its normal place.
+1
PATCH 1/1 drm/atomic: Delete an unnecessary check before drm_property_unreference_blob()
In reply to Daniel VetterFrom: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 17:54:32 +0200
The drm_property_unreference_blob() function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/drm_atomic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic.c +1 -2
@@ -404,8 +404,7 @@ drm_atomic_replace_property_blob(struct drm_property_blob **blob,if (old_blob == new_blob)return ; -if (old_blob) -drm_property_unreference_blob (old_blob); +drm_property_unreference_blob (old_blob);if (new_blob)drm_property_reference_blob (new_blob); *blob = new_blob;
Signature · 1 line
2.9.2
PATCH 1/1 GPU-DRM-sun4i: Delete an unnecessary check before drm_fbdev_cma_hotplug_event()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 18:32:34 +0200
The drm_fbdev_cma_hotplug_event() function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/sun4i/sun4i_framebuffer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/sun4i/sun4i_framebuffer.c +1 -2
@@ -20,8 +20,7 @@ static void sun4i_de_output_poll_changed(struct drm_device *drm) {struct sun4i_drv *drv = drm->dev_private; -if (drv->fbdev) -drm_fbdev_cma_hotplug_event (drv->fbdev); +drm_fbdev_cma_hotplug_event (drv->fbdev); }static const struct drm_mode_config_funcs sun4i_de_mode_config_funcs = {
Signature · 1 line
2.9.2
Re: [PATCH] drm/atomic: Delete an unnecessary check before drm_property_unreference_blob()
In reply to SF Markus ElfringQuoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 17:54:32 +0200The
drm_property_unreference_blob()function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/drm_atomic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/drm_atomic.c +0
-0
drivers/gpu/drm/drm_atomic.c drm_atomic_replace_property_blob(struct drm_property_blob **blob, · line 409
Quoted 8 lines
drivers/gpu/drm/drm_atomic.c +1
-2@@ -404,8 +404,7 @@ drm_atomic_replace_property_blob(struct drm_property_blob **blob,if (old_blob = new_blob)return ; -if (old_blob) -drm_property_unreference_blob (old_blob); +drm_property_unreference_blob (old_blob);if (new_blob)drm_property_reference_blob (new_blob);
I wonder whether it'd be worthwhile to add the same check to drm_property_reference_blob to make things symmetric.
Musings aside, I've applied this to drm-misc.
Sean
Quoted 8 lines
drivers/gpu/drm/drm_atomic.c +0
-1*blob = new_blob; --2.9.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Daniel Vetter
AppliedRe: [PATCH] GPU-DRM-sun4i: Delete an unnecessary check before drm_fbdev_cma_hotplug_event()
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 18:32:34 +0200The
drm_fbdev_cma_hotplug_event()function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied to drm-misc, thanks.
-Daniel
Quoted 21 lines
--- drivers/gpu/drm/sun4i/sun4i_framebuffer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/sun4i/sun4i_framebuffer.c +1
-2@@ -20,8 +20,7 @@ static void sun4i_de_output_poll_changed(struct drm_device *drm) {struct sun4i_drv *drv = drm->dev_private; -if (drv->fbdev) -drm_fbdev_cma_hotplug_event (drv->fbdev); +drm_fbdev_cma_hotplug_event (drv->fbdev); }static const struct drm_mode_config_funcs sun4i_de_mode_config_funcs = {Signature · 1 line
2.9.2
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
PATCH 1/1 GPU-DRM-nouveau: Delete an unnecessary check before the function call "pci_dev_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 20 Jul 2016 19:43:27 +0200
The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/nouveau/nouveau_drm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -2
@@ -525,8 +525,7 @@ nouveau_drm_unload(struct drm_device *dev)nouveau_vga_fini (drm);nvif_device_fini (&drm->device); -if (drm->hdmi_device) -pci_dev_put (drm->hdmi_device); +pci_dev_put (drm->hdmi_device);nouveau_cli_destroy (&drm->client);return 0 ; }
Signature · 1 line
2.9.2
Re: staging: ks7010: Rename jump labels
In reply to Wolfram SangQuoted 3 lines
Quoted 1 line
Adjust jump targets according to the Linux coding style convention.
Really? Is that documented somewhere?
How do you think about information from the chapter "7: Centralized exiting of functions"?
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodingStyle?idGef4ad2684d380dd6d596140fb79395115c3950#n389
Quoted 4 lines
Quoting Jean Delvare:
"> It is generally accepted to indent labels with a single space. This
Quoted 1 line
avoids breaking the -p option of diff."
Would you like to take another look at the warning "LEADING_SPACE"?
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/scripts/checkpatch.pl?idGef4ad2684d380dd6d596140fb79395115c3950#n3004
Does such a check need further considerations?
Quoted 1 line
So, NACK for now unless we know 'diff' has been fixed.
I am also curious on corresponding software evolution.
Regards,
Markus
Re: [PATCH 3/9] staging: ks7010: Return directly after a failed kmalloc()
In reply to Wolfram SangQuoted 13 lines
Quoted 12 lines
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) · line 717
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c +2
-4@@ -713,10 +713,8 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)unsigned char *data_buf; data_buf =kmalloc (sizeof (u32),GFP_KERNEL ); -if (!data_buf) { - rc =1 ; - goto error_out; - } +if (!data_buf) +return 1 ;One could rather wonder why the function has such strange error values...
Quoted 1 line
Agreed. Markus, can you check if we can use
-ENOMEMin those places.
I find that I do not know this software good enough at the moment so that I could safely decide on the shown special error values. I guess that further clarification might be needed for affected implementation details.
Regards,
Markus
Re: [PATCH 5/9] staging: ks7010: Delete unnecessary uses of the variable "retval"
In reply to Wolfram SangQuoted 22 lines
Quoted 10 lines
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c +0
-1@@ -90,7 +90,6 @@ static int ks7010_sdio_write(struct ks_wlan_private *priv, unsigned int address,void ks_wlan_hw_sleep_doze_request (struct ks_wlan_private *priv) {unsigned char rw_data; -int retval;DPRINTK (4 ,"\n" );@@ -99,9 +98,10 @@ void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv)Quoted 11 lines
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 104
Quoted 8 lines
drivers/staging/ks7010/ks7010_sdio.c +4
-2if (atomic_read (&priv->sleepstatus.status) =0 ) { rw_data =GCR_B_DOZE ; - retval >>> - ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {A multi-line function call in an if test does not look nice at all. The original code was an easy-to-read expectable pattern.
Quoted 2 lines
I agree. I am not strict on the 80 char limit, especially in cases like the above.
Would you try an other source code formatting for the suggested change pattern?
Regards,
Markus
Re: staging: ks7010: Rename jump labels
In reply to SF Markus ElfringHello Markus, Wolfram,
Quoted 6 lines · SF Markus Elfring
Quoted 3 lines
Quoted 1 line
Adjust jump targets according to the Linux coding style convention.
Really? Is that documented somewhere?
How do you think about information from the chapter "7: Centralized exiting of functions"?
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodingStyle?idGef4ad2684d380dd6d596140fb79395115c3950#n389
I'm not impressed by this piece of documentation. For example, <<also don't name them after the goto location like "err_kmalloc_failed:">> is as unclear as you can get. It would be much better to tell what to name them, if the author thinks it really matters. (Personally I think it is out of scope of coding style rules.)
Back to the lack of space before labels, it's at best a personal preference. If you insist on standardizing, I'd call it a bug in the documentation, which should be fixed. One space before label is the way to go.
Quoted 1 line
Quoted 1 line
Quoting Jean Delvare:
I'm honored :)
Quoted 7 lines
Quoted 2 lines
"> It is generally accepted to indent labels with a single space. This
Quoted 1 line
avoids breaking the -p option of diff."
Would you like to take another look at the warning "
LEADING_SPACE"?
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/scripts/checkpatch.pl?idGef4ad2684d380dd6d596140fb79395115c3950#n3004Does such a check need further considerations?
checkpatch has become so complex, it's full of false positives, trying to enforce rules just because one developer wants to force his view on all others. I stopped following everything the script says long ago. I'm cherry-picking now.
That being said... checkpatch does not complain about leading space before labels. Not even with --strict. So why are you mentioning it here?
Quoted 1 line
Quoted 1 line
So, NACK for now unless we know 'diff' has been fixed.
Full nack from myself as well. Just looking at the thread on lkml makes me feel dizzy. When you are about to send that amount of messages, you should pause and think again. Is it really worth it? I think I'd be less annoyed by regular spam.
Quoted 1 line
I am also curious on corresponding software evolution.
I wouldn't consider it a bug. Despite the description of option -p in the diff man page calling it C specific, it looks very generic to me. As I understand it, it looks for any line not starting with a blank and containing at least one letter (or maybe just starting with a letter - I didn't look at the code.) Thankfully it doesn't try to parse C. So it depends on how you indent your code. Live with it.
It's been that way for so long that changing it now is hardly an option. That change would be seen as a gratuitous regression by many (including myself.) And for the record, "git diff" behaves exactly the same. So it's a de facto standard.
Signature · 2 lines
Jean Delvare SUSE L3 Support
Wolfram Sang
Acked-byRe: [PATCH 3/9] staging: ks7010: Return directly after a failed kmalloc()
In reply to SF Markus ElfringQuoted 13 lines · SF Markus Elfring
Quoted 13 lines
Quoted 12 lines
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) · line 717
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c +2
-4@@ -713,10 +713,8 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)unsigned char *data_buf; data_buf =kmalloc (sizeof (u32),GFP_KERNEL ); -if (!data_buf) { - rc =1 ; - goto error_out; - } +if (!data_buf) +return 1 ;One could rather wonder why the function has such strange error values...
Quoted 6 lines
Quoted 1 line
Agreed. Markus, can you check if we can use
-ENOMEMin those places.I find that I do not know this software good enough at the moment so that I could safely decide on the shown special error values. I guess that further clarification might be needed for affected implementation details.
That's OK, too.
Re: staging: ks7010: Rename jump labels
In reply to Jean DelvareThank you very much for the heads up, Jean!
Re: [PATCH 5/9] staging: ks7010: Delete unnecessary uses of the variable "retval"
In reply to SF Markus ElfringQuoted 14 lines
Quoted 14 lines
Quoted 13 lines
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 104
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c +4
-3if (atomic_read (&priv->sleepstatus.status) ==0 ) { rw_data =GCR_B_DOZE ; - retval = -ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {A multi-line function call in an if test does not look nice at all. The original code was an easy-to-read expectable pattern.
Quoted 4 lines
Quoted 2 lines
I agree. I am not strict on the 80 char limit, especially in cases like the above.
Would you try an other source code formatting for the suggested change pattern?
I don't understand the question?
Re: [PATCH 5/9] staging: ks7010: Delete unnecessary uses of the variable "retval"
Quoted 13 lines · Wolfram Sang
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 104
Quoted 9 lines
drivers/staging/ks7010/ks7010_sdio.c +4
-2if (atomic_read (&priv->sleepstatus.status) =0 ) { rw_data =GCR_B_DOZE ; - retval > > >>> - ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {A multi-line function call in an if test does not look nice at all. The original code was an easy-to-read expectable pattern.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
I agree. I am not strict on the 80 char limit, especially in cases like the above.
Would you try an other source code formatting for the suggested change pattern?
I don't understand the question?
I think the original code was fine. x = blah(); if (x) ... is a perfectly familiar kernel coding pattern. There is no benefit in terms of performance or understandability in dropping the variable.
julia
Re: [PATCH 5/9] staging: ks7010: Delete unnecessary uses of the variable "retval"
Quoted 21 lines · Julia Lawall
Quoted 17 lines · Wolfram Sang
Quoted 17 lines
Quoted 16 lines
Quoted 13 lines
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 104
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c +4
-3if (atomic_read (&priv->sleepstatus.status) ==0 ) { rw_data =GCR_B_DOZE ; - retval = -ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {A multi-line function call in an if test does not look nice at all. The original code was an easy-to-read expectable pattern.
I agree. I am not strict on the 80 char limit, especially in cases like the above.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Would you try an other source code formatting for the suggested change pattern?
I don't understand the question?
I think the original code was fine. x =
blah(); if (x) ... is a perfectly familiar kernel coding pattern. There is no benefit in terms of performance or understandability in dropping the variable.
I certainly agree to that.
Re: staging: ks7010: Rename jump labels
In reply to Jean DelvareQuoted 4 lines
Quoted 2 lines
How do you think about information from the chapter "7: Centralized exiting of functions"?
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodingStyle?idGef4ad2684d380dd6d596140fb79395115c3950#n389I'm not impressed by this piece of documentation.
I would also appreciate further improvements there.
Quoted 3 lines
Back to the lack of space before labels, it's at best a personal preference. If you insist on standardizing, I'd call it a bug in the documentation, which should be fixed. One space before label is the way to go.
Would you like to contribute another patch for such a coding style issue?
Quoted 2 lines
That being said... checkpatch does not complain about leading space before labels. Not even with --strict. So why are you mentioning it here?
How do you think about a similar software update?
staging: lustre: Fix a jump label position in osc_get_info()
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?idÇ1d264543f759fea147734cb63de36397817534
https://lkml.org/lkml/2015/12/21/401
Quoted 1 line
Just looking at the thread on lkml makes me feel dizzy.
I understand your concern to some degree.
Quoted 2 lines
When you are about to send that amount of messages, you should pause and think again.
This happened already.
Quoted 1 line
Is it really worth it?
I came to such a conclusion for the shown source code clean-up. Some software developers can also support it.
Quoted 1 line
I think I'd be less annoyed by regular spam.
It can be harder occasionally to become familiar and comfortable with the suggested change pattern.
Could you accept other details from my update suggestion?
Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: staging: ks7010: Delete unnecessary uses of the variable "retval"
In reply to Julia LawallQuoted 1 line
I think the original code was fine.
I suggest to reconsider involved implementation details once more.
Quoted 1 line
x =
blah(); if (x) ... is a perfectly familiar kernel coding pattern.
I can agree to such a general information.
Quoted 1 line
There is no benefit in terms of performance
It might be possible that a good compiler can also optimise some unnecessary variable accesses away.
Examples for further background information:
* "Minimize local variables"
https://eventhelix.com/realtimemantra/basics/optimizingcandcppcode.htm#Minimize%20Local%20Variables
* "Temporary Objects" by Danny Kalev
http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum8
Quoted 1 line
or understandability in dropping the variable.
I guess that we have got different opinions on such an aspect.
* Do you really want to assign every return value from a function call to an extra variable before it is used again?
* How many reading and understanding capacity do you need for each extra variable?
Regards,
Markus
Re: staging: ks7010: Delete unnecessary uses of the variable "retval"
Quoted 7 lines · SF Markus Elfring
Quoted 1 line
I think the original code was fine.
I suggest to reconsider involved implementation details once more.
Quoted 1 line
x =
blah(); if (x) ... is a perfectly familiar kernel coding pattern.
Quoted 7 lines
I can agree to such a general information.
Quoted 1 line
There is no benefit in terms of performance
It might be possible that a good compiler can also optimise some unnecessary variable accesses away.
A compiler written by an undergrad can optimize the variable away in this case. That's what compilers do.
Quoted 8 lines
Examples for further background information:
* "Minimize local variables"
https://eventhelix.com/realtimemantra/basics/optimizingcandcppcode.htm#Minimize%20Local%20Variables* "Temporary Objects" by Danny Kalev
http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum8
Quoted 6 lines
Quoted 1 line
or understandability in dropping the variable.
I guess that we have got different opinions on such an aspect.
* Do you really want to assign every return value from a function call to an extra variable before it is used again?
If it's a choice between 1) function call on many lines, 2) function call over 80 characters, and 3) extra variable, I definitely prefer the extra variable.
julia
Quoted 11 lines
* How many reading and understanding capacity do you need for each extra variable?
Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: staging: ks7010: Delete unnecessary uses of the variable "retval"
In reply to Wolfram SangQuoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 104
Quoted 8 lines
drivers/staging/ks7010/ks7010_sdio.c +4
-2if (atomic_read (&priv->sleepstatus.status) =0 ) { rw_data =GCR_B_DOZE ; - retval >>>>> - ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {A multi-line function call in an if test does not look nice at all. The original code was an easy-to-read expectable pattern.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
I agree. I am not strict on the 80 char limit, especially in cases like the above.
Will this line length limitation trigger any more collateral evolution in the discussed software module?
Quoted 3 lines
Quoted 1 line
Would you try an other source code formatting for the suggested change pattern?
I don't understand the question?
Can you follow expectations around the proposed refactoring of any function implementations?
Regards,
Markus
Re: [PATCH 9/9] staging: ks7010: Delete three unnecessary variable initialisations
In reply to Julia LawallQuoted 6 lines
Quoted 6 lines
drivers/staging/ks7010/ks7010_sdio.c +0
-1@@ -323,14 +323,14 @@ static void tx_device_task(void *dev) {struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;struct tx_device_buffer *sp; -int rc =0 ;
Quoted 13 lines
drivers/staging/ks7010/ks7010_sdio.c static void tx_device_task(void *dev) · line 332
Quoted 7 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-1DPRINTK (4 ,"\n" );if (cnt_txqbody (priv) >0 &&atomic_read (&priv->psstatus.status) !=PS_SNOOZE ) { sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead];if (priv->dev_state >=DEVICE_STATE_BOOT ) { - rc =write_to_device (priv, sp->sendp, sp->size); +int rc =write_to_device (priv, sp->sendp, sp->size);This does not look appealing to me, neither the declaration in the middle of the function, nor the intiialization to the result of a complex expression, nor the separation of the call and the error checking code by a blank line. There is nothing wrong with having the rc variable be declared at the the top of the function, in its normal place.
* Do you occasionally care for a refactoring like "Reduce scope of variable"?
http://refactoring.com/catalog/reduceScopeOfVariable.html
* How do you think about to remove the extra assignment at the beginning of this function implementation?
Regards,
Markus
Re: [PATCH 9/9] staging: ks7010: Delete three unnecessary variable initialisations
Quoted 20 lines · SF Markus Elfring
Quoted 6 lines
Quoted 6 lines
drivers/staging/ks7010/ks7010_sdio.c +0
-1@@ -323,14 +323,14 @@ static void tx_device_task(void *dev) {struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;struct tx_device_buffer *sp; -int rc =0 ;Quoted 13 lines
drivers/staging/ks7010/ks7010_sdio.c static void tx_device_task(void *dev) · line 332
Quoted 7 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-1DPRINTK (4 ,"\n" );if (cnt_txqbody (priv) >0 &&atomic_read (&priv->psstatus.status) !=PS_SNOOZE ) { sp = &priv->tx_dev.tx_dev_buff[priv->tx_dev.qhead];if (priv->dev_state >=DEVICE_STATE_BOOT ) { - rc =write_to_device (priv, sp->sendp, sp->size); +int rc =write_to_device (priv, sp->sendp, sp->size);This does not look appealing to me, neither the declaration in the middle of the function, nor the intiialization to the result of a complex expression, nor the separation of the call and the error checking code by a blank line. There is nothing wrong with having the rc variable be declared at the the top of the function, in its normal place.
Quoted 3 lines
* Do you occasionally care for a refactoring like "Reduce scope of variable"?
Probably not. Certainly not in this case.
Quoted 2 lines
* How do you think about to remove the extra assignment at the beginning of this function implementation?
If the value is not useful, then it can go.
julia
Quoted 7 lines
Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: staging: ks7010: Delete three unnecessary variable initialisations
Quoted 5 lines
Quoted 3 lines
* Do you occasionally care for a refactoring like "Reduce scope of variable"?
Probably not. Certainly not in this case.
In which use cases would the suggested change pattern be more interesting for you?
Regards,
Markus
Re: staging: ks7010: Rename jump labels
In reply to Jean DelvareQuoted 2 lines
That being said... checkpatch does not complain about leading space before labels. Not even with --strict. So why are you mentioning it here?
I remembered a warning like "INDENTED_LABEL" instead.
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/scripts/checkpatch.pl?id’d21ac74a9e3c09b0b01c764e530657e4c85c49#n4326
How do you generally think about jump label renaming?
Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: staging: ks7010: Delete unnecessary uses of the variable "retval"
In reply to Julia LawallQuoted 7 lines
Quoted 3 lines
* Do you really want to assign every return value from a function call to an extra variable before it is used again?
If it's a choice between 1) function call on many lines, 2) function call over 80 characters, and 3) extra variable, I definitely prefer the extra variable.
+1
Re: staging: ks7010: Delete unnecessary uses of the variable "retval"
In reply to SF Markus ElfringQuoted 20 lines · SF Markus Elfring
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
drivers/staging/ks7010/ks7010_sdio.c void ks_wlan_hw_sleep_doze_request(struct ks_wlan_private *priv) · line 104
Quoted 9 lines
drivers/staging/ks7010/ks7010_sdio.c +4
-3if (atomic_read (&priv->sleepstatus.status) ==0 ) { rw_data =GCR_B_DOZE ; - retval = -ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv, +GCR_B , + &rw_data, +sizeof (rw_data))) {A multi-line function call in an if test does not look nice at all. The original code was an easy-to-read expectable pattern.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
I agree. I am not strict on the 80 char limit, especially in cases like the above.
Will this line length limitation trigger any more collateral evolution in the discussed software module?
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Would you try an other source code formatting for the suggested change pattern?
I don't understand the question?
Can you follow expectations around the proposed refactoring of any function implementations?
I don't understand both questions. Maybe you need to give examples?
PATCH 1/1 GPU-DRM-Exynos: Delete an unnecessary check before the function call "vunmap"
In reply to Joonyoung ShimFrom: Markus Elfring <[email protected]>
Date: Thu, 21 Jul 2016 19:23:25 +0200
The vunmap() function performs also input parameter validation. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +1 -2
@@ -269,8 +269,7 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev,struct exynos_drm_gem *exynos_gem = exynos_fbd->exynos_gem;struct drm_framebuffer *fb; -if (exynos_gem->kvaddr) -vunmap (exynos_gem->kvaddr); +vunmap (exynos_gem->kvaddr);/* release drm framebuffer and real buffer */ if (fb_helper->fb && fb_helper->fb->funcs) {
Signature · 1 line
2.9.2
Sean Paul
AppliedRe: [PATCH] GPU-DRM-Exynos: Delete an unnecessary check before the function call "vunmap"
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 21 Jul 2016 19:23:25 +0200The
vunmap()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied to drm-misc
Quoted 25 lines
--- drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/exynos/exynos_drm_fbdev.c +1
-3@@ -269,8 +269,7 @@ static void exynos_drm_fbdev_destroy(struct drm_device *dev,struct exynos_drm_gem *exynos_gem = exynos_fbd->exynos_gem;struct drm_framebuffer *fb; -if (exynos_gem->kvaddr) -vunmap (exynos_gem->kvaddr); +vunmap (exynos_gem->kvaddr);/* release drm framebuffer and real buffer */ if (fb_helper->fb && fb_helper->fb->funcs) { --2.9.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
[Cocci] Changing return value determination in if statements with SmPL
In reply to Wolfram SangHello,
I am trying the software combination "spatch version 1.0.5-00058-g36edc2b-dirty compiled with OCaml version 4.03.0" out a bit more with the following approach.
@checking_function_calls_directly@
identifier checker, retval, work;
parameter list pl;
statement is, es;
type rt;
@@
rt checker(...)
{
...
-retval = work(pl);
if (
- retval
+ work(pl)
)
is else
es
...
}
elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt -sp-file checking_function_calls_directly1.cocci ~/Projekte/Linux/next-patched/drivers/staging/ks7010/ks7010_sdio.cinit_defs_builtins: /usr/local/lib64/coccinelle/standard.h
minus: parse error:
File "checking_function_calls_directly1.cocci", line 10, column 15, charpos = 151
around = 'pl',
whole content = -retval = work(pl);
Do I overlook anything in my SmPL script?
Regards,
Markus
Re: staging: ks7010: Rename jump labels
In reply to SF Markus ElfringHi Markus,
Quoted 5 lines · SF Markus Elfring
Quoted 2 lines
That being said... checkpatch does not complain about leading space before labels. Not even with --strict. So why are you mentioning it here?
I remembered a warning like "
INDENTED_LABEL" instead.
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/scripts/checkpatch.pl?id’d21ac74a9e3c09b0b01c764e530657e4c85c49#n4326
"#goto labels aren't indented, allow a single space however"
Can't be clearer :-)
Quoted 1 line
How do you generally think about jump label renaming?
Renaming from "out0:", "out1:" etc to something meaningful, yes. Did you have anything else in mind?
Signature · 6 lines
Jean Delvare SUSE L3 Support -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
[Cocci] Changing return value determination in if statements with SmPL
In reply to SF Markus ElfringQuoted 36 lines · SF Markus Elfring
Hello,
I am trying the software combination "spatch version 1.0.5-00058-g36edc2b-dirty compiled with OCaml version 4.03.0" out a bit more with the following approach.
@checking_function_calls_directly@
identifier checker, retval, work;
parameter list pl;
statement is, es;
type rt;
@@
rt checker(...)
{
...(quoted diff) +1
-2-retval = work(pl); if ( - retval + work(pl) ) is else es }elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt -sp-file
checking_function_calls_directly1.cocci~/Projekte/Linux/next-patched/drivers/staging/ks7010/ks7010_sdio.cinit_defs_builtins:/usr/local/lib64/coccinelle/standard.h
minus: parse error:
File "checking_function_calls_directly1.cocci", line 10, column 15, charpos = 151
around = 'pl',
whole content = -retval = work(pl);
Quoted 1 line
Do I overlook anything in my SmPL script?
A parameter list is something that comes after the name of a function in the function header. Something like int x, int y, in foo (int x, int y) { ... }. Probably you want an expression list.
julia
Re: staging: ks7010: Rename jump labels
In reply to Jean DelvareQuoted 5 lines
"#goto labels aren't indented, allow a single space however"
Can't be clearer :-)
Should such information from a comment in this script be also explicitly mentioned in the document "CodingStyle" anyhow?
How should the support for indentation of jump labels with
a single space be expressed in all relevant Linux development documentation?
Quoted 3 lines
Quoted 1 line
How do you generally think about jump label renaming?
Renaming from "out0:", "out1:" etc to something meaningful, yes.
I suggest to take another look at such identifiers.
Would you like to support the renaming of a label like "error_out1" (in the function "ks7010_upload_firmware" for example)?
Quoted 1 line
Did you have anything else in mind?
Not really for this update suggestion.
Will the software evolution be continued also with information from the topic "Source code review around jump label usage"?
https://lkml.org/lkml/2015/12/11/378
http://article.gmane.org/gmane.linux.kernel/2106190
Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Cocci] Changing return value determination in if statements with SmPL
In reply to Julia LawallQuoted 3 lines
A parameter list is something that comes after the name of a function in the function header. Something like int x, int y, in foo (int x, int y) { ... }. Probably you want an expression list.
* How do you call the list usually that is used for the definition before the function body?
* Did I get inappropriate expectations from a description around a "parameter-list-declarator"?
http://en.cppreference.com/w/c/language/function_definition
* The following SmPL script variant seems to work better.
@checking_function_calls_directly@
identifier checker, retval, work;
expression list el;
statement is, es;
type rt;
@@
rt checker(...)
{
<+...
-retval = work(el);
if (
- retval
+ work(el)
)
is else
es
...+>
}
elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt -sp-file checking_function_calls_directly2.cocci ~/Projekte/Linux/next-patched/drivers/staging/ks7010/ks7010_sdio.cinit_defs_builtins: /usr/local/lib64/coccinelle/standard.h
HANDLING: /home/elfring/Projekte/Linux/next-patched/drivers/staging/ks7010/ks7010_sdio.c
tmp/cocci-output-1578-3a5e93-ks7010_sdio.c renamed from home/elfring/Projekte/Linux/next-patched/drivers/staging/ks7010/ks7010_sdio.c +1 -3
@@ -99,9 +99,7 @@ void ks_wlan_hw_sleep_doze_request(strucif (atomic_read (&priv->sleepstatus.status) ==0 ) { rw_data =GCR_B_DOZE ; - retval = -ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data))) {DPRINTK (1 ," error : GCR_B=%02X\n" , rw_data); goto out; }
?
Regards,
Markus
[Cocci] Changing return value determination in if statements with SmPL
Quoted 6 lines · SF Markus Elfring
Quoted 3 lines
A parameter list is something that comes after the name of a function in the function header. Something like int x, int y, in foo (int x, int y) { ... }. Probably you want an expression list.
* How do you call the list usually that is used for the definition before the function body?
parameter list
Quoted 4 lines
* Did I get inappropriate expectations from a description around a "parameter-list-declarator"?
http://en.cppreference.com/w/c/language/function_definition
Apparently. A link from taht page quite clearly says:
parameter-list - either the single keyword void or a
comma-separated list of parameters, which may end with an ellipsis parameter
julia
Quoted 47 lines
* The following SmPL script variant seems to work better.
@checking_function_calls_directly@
identifier checker, retval, work;
expression list el;
statement is, es;
type rt;
@@
rt checker(...)
{
<+...(quoted diff) +1
-2-retval = work(el); if ( - retval + work(el) ) is else es ...+> }elfring at Sonne:~/Projekte/Coccinelle/janitor> spatch.opt -sp-file
checking_function_calls_directly2.cocci~/Projekte/Linux/next-patched/drivers/staging/ks7010/ks7010_sdio.cinit_defs_builtins:/usr/local/lib64/coccinelle/standard.h
HANDLING:/home/elfring/Projekte/Linux/next-patched/drivers/staging/ks7010/ks7010_sdio.c
diff =tmp/cocci-output-1578-3a5e93-ks7010_sdio.c renamed from home/elfring/Projekte/Linux/next-patched/drivers/staging/ks7010/ks7010_sdio.c +1
-3@@ -99,9 +99,7 @@ void ks_wlan_hw_sleep_doze_request(strucif (atomic_read (&priv->sleepstatus.status) ==0 ) { rw_data =GCR_B_DOZE ; - retval = -ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_write (priv,GCR_B , &rw_data,sizeof (rw_data))) {DPRINTK (1 ," error : GCR_B=%02X\n" , rw_data); goto out; }?
Regards,
Markus
[Cocci] Better explanation for the usage of expression/parameter lists with SmPL?
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
A parameter list is something that comes after the name of a function in the function header. Something like int x, int y, in foo (int x, int y) { ... }. Probably you want an expression list.
* How do you call the list usually that is used for the definition before the function body?
parameter list
It seems that we have got the same understanding here.
Quoted 4 lines
Quoted 2 lines
* Did I get inappropriate expectations from a description around a "parameter-list-declarator"?
http://en.cppreference.com/w/c/language/function_definitionApparently.
I am surprised by this feedback.
Quoted 2 lines
parameter-list - either the single keyword void or a comma-separated list of parameters, which may end with an ellipsis parameter
How does this description fit to the term "expression list" in the semantic patch language?
Regards,
Markus
[Cocci] Better explanation for the usage of expression/parameter lists with SmPL?
Quoted 17 lines · SF Markus Elfring
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
A parameter list is something that comes after the name of a function in the function header. Something like int x, int y, in foo (int x, int y) { ... }. Probably you want an expression list.
* How do you call the list usually that is used for the definition before the function body?
parameter list
It seems that we have got the same understanding here.
Quoted 4 lines
Quoted 2 lines
* Did I get inappropriate expectations from a description around a "parameter-list-declarator"?
http://en.cppreference.com/w/c/language/function_definitionApparently.
Quoted 8 lines
I am surprised by this feedback.
Quoted 2 lines
parameter-list - either the single keyword void or a comma-separated list of parameters, which may end with an ellipsis parameter
How does this description fit to the term "expression list" in the semantic patch language?
Not at all.
int f(int x, int y) <---- parameter list
{
g(1, 2, 3, 4, 5): <---- expression list
}
julia
[Cocci] Better explanation for the usage of expression/parameter lists with SmPL?
Quoted 4 lines
int
f(int x, int y)<---- parameter list{ g(1, 2, 3, 4, 5): <---- expression list }
I'm sorry if I were confused too much about these places for a moment. Thanks for your quick help.
Regards,
Markus
Re: staging: ks7010: Delete unnecessary uses of the variable "retval"
In reply to Wolfram SangQuoted 4 lines
Quoted 2 lines
Can you follow expectations around the proposed refactoring of any function implementations?
I don't understand both questions. Maybe you need to give examples?
I suggest to try the following script (semantic patch for working with the Coccinelle software) out on the discussed source files.
@checking_function_calls_directly@
identifier checker, retval, work;
expression list el;
statement is, es;
type rt;
@@
rt checker(...)
{
<+...
-retval = work(el);
if (
- retval
+ work(el)
)
is else
es
...+>
}
Do you find such a source code transformation useful?
Regards,
Markus
Re: staging: ks7010: Delete unnecessary uses of the variable "retval"
Quoted 2 lines
Do you find such a source code transformation useful?
No. I already gave that answer by agreeing to Julia's viewpoint.
PATCH 1/1 GPU-DRM-OMAP: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 08:28:31 +0200
The following functions test whether their argument is NULL and then return immediately.
* backlight_device_unregister
* drm_gem_object_unreference_unlocked
Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c | 3 +-- drivers/gpu/drm/omapdrm/omap_fb.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/omapdrm/displays/panel-dsi-cm.c +1 -2
@@ -1284,8 +1284,7 @@ static int dsicm_probe(struct platform_device *pdev)return 0 ; err_sysfs_create: -if (bldev !=NULL ) -backlight_device_unregister (bldev); +backlight_device_unregister (bldev); err_bl:destroy_workqueue (ddata->workqueue); err_reg:
drivers/gpu/drm/omapdrm/omap_fb.c +2 -2
@@ -115,8 +115,8 @@ static void omap_framebuffer_destroy(struct drm_framebuffer *fb)for (i =0 ; i < n; i++) {struct plane *plane = &omap_fb->planes[i]; -if (plane->bo) -drm_gem_object_unreference_unlocked (plane->bo); + +drm_gem_object_unreference_unlocked (plane->bo); }kfree (omap_fb);
Signature · 1 line
2.9.2
Re: staging: ks7010: Return directly after a failed kmalloc()
In reply to Wolfram SangQuoted 6 lines
Quoted 2 lines
I guess that further clarification might be needed for affected implementation details.
That's OK, too.
Acked-by Wolfram Sang <[email protected]>
Does this acknowledgement include also the acceptance for the suggested change around calls of the functions "sdio_claim_host" and "sdio_release_host" within the implementation of the function "ks7010_upload_firmware"?
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/staging/ks7010/ks7010_sdio.c?id123042d0dbf7635f052efc2ae69fd9af624f1d#n771
Regards,
Markus
Re: staging: ks7010: Return directly after a failed kmalloc()
Quoted 11 lines · SF Markus Elfring
Quoted 6 lines
Quoted 2 lines
I guess that further clarification might be needed for affected implementation details.
That's OK, too.
Acked-by Wolfram Sang <[email protected]>Does this acknowledgement include also the acceptance for the suggested change around calls of the functions "
sdio_claim_host" and "sdio_release_host" within the implementation of the function "ks7010_upload_firmware"?
Likely. Send a patch and we will see.
PATCH 1/1 GPU-DRM-GMA500: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 10:30:30 +0200
The functions pci_dev_put() and psb_intel_i2c_destroy() test whether their argument is NULL and then return immediately.
Thus the tests around their calls are not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/gma500/cdv_intel_hdmi.c | 3 +-- drivers/gpu/drm/gma500/cdv_intel_lvds.c | 9 +++------ drivers/gpu/drm/gma500/psb_drv.c | 6 ++---- drivers/gpu/drm/gma500/psb_intel_lvds.c | 9 +++------ 4 files changed, 9 insertions(+), 18 deletions(-)
drivers/gpu/drm/gma500/cdv_intel_hdmi.c +1 -2
@@ -246,8 +246,7 @@ static void cdv_hdmi_destroy(struct drm_connector *connector) {struct gma_encoder *gma_encoder =gma_attached_encoder (connector); -if (gma_encoder->i2c_bus) -psb_intel_i2c_destroy (gma_encoder->i2c_bus); +psb_intel_i2c_destroy (gma_encoder->i2c_bus);drm_connector_unregister (connector);drm_connector_cleanup (connector);kfree (connector);
drivers/gpu/drm/gma500/cdv_intel_lvds.c +3 -6
@@ -444,8 +444,7 @@ static void cdv_intel_lvds_destroy(struct drm_connector *connector) {struct gma_encoder *gma_encoder =gma_attached_encoder (connector); -if (gma_encoder->i2c_bus) -psb_intel_i2c_destroy (gma_encoder->i2c_bus); +psb_intel_i2c_destroy (gma_encoder->i2c_bus);drm_connector_unregister (connector);drm_connector_cleanup (connector);kfree (connector);
@@ -780,12 +779,10 @@ out: failed_find:mutex_unlock (&dev->mode_config.mutex);printk (KERN_ERR "Failed find\n" ); -if (gma_encoder->ddc_bus) -psb_intel_i2c_destroy (gma_encoder->ddc_bus); +psb_intel_i2c_destroy (gma_encoder->ddc_bus); failed_ddc:printk (KERN_ERR "Failed DDC\n" ); -if (gma_encoder->i2c_bus) -psb_intel_i2c_destroy (gma_encoder->i2c_bus); +psb_intel_i2c_destroy (gma_encoder->i2c_bus); failed_blc_i2c:printk (KERN_ERR "Failed BLC\n" );drm_encoder_cleanup (encoder);
drivers/gpu/drm/gma500/psb_drv.c +2 -4
@@ -210,10 +210,8 @@ static int psb_driver_unload(struct drm_device *dev)iounmap (dev_priv->aux_reg); dev_priv->aux_reg =NULL ; } -if (dev_priv->aux_pdev) -pci_dev_put (dev_priv->aux_pdev); -if (dev_priv->lpc_pdev) -pci_dev_put (dev_priv->lpc_pdev); +pci_dev_put (dev_priv->aux_pdev); +pci_dev_put (dev_priv->lpc_pdev);/* Destroy VBT data */ psb_intel_destroy_bios (dev);
drivers/gpu/drm/gma500/psb_intel_lvds.c +3 -6
@@ -561,8 +561,7 @@ void psb_intel_lvds_destroy(struct drm_connector *connector)struct gma_encoder *gma_encoder =gma_attached_encoder (connector);struct psb_intel_lvds_priv *lvds_priv = gma_encoder->dev_priv; -if (lvds_priv->ddc_bus) -psb_intel_i2c_destroy (lvds_priv->ddc_bus); +psb_intel_i2c_destroy (lvds_priv->ddc_bus);drm_connector_unregister (connector);drm_connector_cleanup (connector);kfree (connector);
@@ -835,11 +834,9 @@ out: failed_find:mutex_unlock (&dev->mode_config.mutex); -if (lvds_priv->ddc_bus) -psb_intel_i2c_destroy (lvds_priv->ddc_bus); +psb_intel_i2c_destroy (lvds_priv->ddc_bus); failed_ddc: -if (lvds_priv->i2c_bus) -psb_intel_i2c_destroy (lvds_priv->i2c_bus); +psb_intel_i2c_destroy (lvds_priv->i2c_bus); failed_blc_i2c:drm_encoder_cleanup (encoder);drm_connector_cleanup (connector);
Signature · 1 line
2.9.2
Re: [PATCH] GPU-DRM-GMA500: Delete unnecessary checks before two function calls
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 10:30:30 +0200The functions
pci_dev_put()andpsb_intel_i2c_destroy()test whether their argument is NULL and then return immediately.
Thus the tests around their calls are not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Two more applied. And your threading still looks funny, all the patches are in-reply to one I don't even have.
-Daniel
Quoted 98 lines
--- drivers/gpu/drm/gma500/cdv_intel_hdmi.c | 3 +-- drivers/gpu/drm/gma500/cdv_intel_lvds.c | 9 +++------ drivers/gpu/drm/gma500/psb_drv.c | 6 ++---- drivers/gpu/drm/gma500/psb_intel_lvds.c | 9 +++------ 4 files changed, 9 insertions(+), 18 deletions(-)drivers/gpu/drm/gma500/cdv_intel_hdmi.c +1
-2@@ -246,8 +246,7 @@ static void cdv_hdmi_destroy(struct drm_connector *connector) {struct gma_encoder *gma_encoder =gma_attached_encoder (connector); -if (gma_encoder->i2c_bus) -psb_intel_i2c_destroy (gma_encoder->i2c_bus); +psb_intel_i2c_destroy (gma_encoder->i2c_bus);drm_connector_unregister (connector);drm_connector_cleanup (connector);kfree (connector);drivers/gpu/drm/gma500/cdv_intel_lvds.c +3
-6@@ -444,8 +444,7 @@ static void cdv_intel_lvds_destroy(struct drm_connector *connector) {struct gma_encoder *gma_encoder =gma_attached_encoder (connector); -if (gma_encoder->i2c_bus) -psb_intel_i2c_destroy (gma_encoder->i2c_bus); +psb_intel_i2c_destroy (gma_encoder->i2c_bus);drm_connector_unregister (connector);drm_connector_cleanup (connector);kfree (connector);@@ -780,12 +779,10 @@ out: failed_find:mutex_unlock (&dev->mode_config.mutex);printk (KERN_ERR "Failed find\n" ); -if (gma_encoder->ddc_bus) -psb_intel_i2c_destroy (gma_encoder->ddc_bus); +psb_intel_i2c_destroy (gma_encoder->ddc_bus); failed_ddc:printk (KERN_ERR "Failed DDC\n" ); -if (gma_encoder->i2c_bus) -psb_intel_i2c_destroy (gma_encoder->i2c_bus); +psb_intel_i2c_destroy (gma_encoder->i2c_bus); failed_blc_i2c:printk (KERN_ERR "Failed BLC\n" );drm_encoder_cleanup (encoder);drivers/gpu/drm/gma500/psb_drv.c +2
-4@@ -210,10 +210,8 @@ static int psb_driver_unload(struct drm_device *dev)iounmap (dev_priv->aux_reg); dev_priv->aux_reg =NULL ; } -if (dev_priv->aux_pdev) -pci_dev_put (dev_priv->aux_pdev); -if (dev_priv->lpc_pdev) -pci_dev_put (dev_priv->lpc_pdev); +pci_dev_put (dev_priv->aux_pdev); +pci_dev_put (dev_priv->lpc_pdev);/* Destroy VBT data */ psb_intel_destroy_bios (dev);drivers/gpu/drm/gma500/psb_intel_lvds.c +3
-6@@ -561,8 +561,7 @@ void psb_intel_lvds_destroy(struct drm_connector *connector)struct gma_encoder *gma_encoder =gma_attached_encoder (connector);struct psb_intel_lvds_priv *lvds_priv = gma_encoder->dev_priv; -if (lvds_priv->ddc_bus) -psb_intel_i2c_destroy (lvds_priv->ddc_bus); +psb_intel_i2c_destroy (lvds_priv->ddc_bus);drm_connector_unregister (connector);drm_connector_cleanup (connector);kfree (connector);@@ -835,11 +834,9 @@ out: failed_find:mutex_unlock (&dev->mode_config.mutex); -if (lvds_priv->ddc_bus) -psb_intel_i2c_destroy (lvds_priv->ddc_bus); +psb_intel_i2c_destroy (lvds_priv->ddc_bus); failed_ddc: -if (lvds_priv->i2c_bus) -psb_intel_i2c_destroy (lvds_priv->i2c_bus); +psb_intel_i2c_destroy (lvds_priv->i2c_bus); failed_blc_i2c:drm_encoder_cleanup (encoder);drm_connector_cleanup (connector);Signature · 1 line
2.9.2
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
PATCH 1/1 drm/mgag200: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 11:20:27 +0200
The drm_gem_object_unreference_unlocked() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/mgag200/mgag200_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/mgag200/mgag200_main.c +2 -2
@@ -17,8 +17,8 @@static void mga_user_framebuffer_destroy (struct drm_framebuffer *fb) {struct mga_framebuffer *mga_fb =to_mga_framebuffer (fb); -if (mga_fb->obj) -drm_gem_object_unreference_unlocked (mga_fb->obj); + +drm_gem_object_unreference_unlocked (mga_fb->obj);drm_framebuffer_cleanup (fb);kfree (fb); }
Signature · 1 line
2.9.2
Re: [PATCH] [media] tw686x-kh: Delete an unnecessary check before the function call "video_unregister_device"
In reply to SF Markus ElfringQuoted 8 lines · SF Markus Elfring
The
video_unregister_device()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/media/tw686x-kh/tw686x-kh-video.c | 3 +--
Thanks.
Signature · 4 lines
Krzysztof Halasa Industrial Research Institute for Automation and Measurements PIAP Al. Jerozolimskie 202, 02-486 Warsaw, Poland
PATCH 1/1 GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 12:48:12 +0200
The drm_property_unreference_blob() function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +1 -3
@@ -112,9 +112,7 @@ static void mtk_drm_crtc_reset(struct drm_crtc *crtc)struct mtk_crtc_state *state;if (crtc->state) { -if (crtc->state->mode_blob) -drm_property_unreference_blob (crtc->state->mode_blob); - +drm_property_unreference_blob (crtc->state->mode_blob); state =to_mtk_crtc_state (crtc->state);memset (state,0 ,sizeof (*state)); }else {
Signature · 1 line
2.9.2
PATCH 1/1 drm/vmwgfx: Delete an unnecessary check before the function call "vfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 13:31:00 +0200
The vfree() function performs also input parameter validation. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +1 -3
@@ -3625,9 +3625,7 @@ static int vmw_resize_cmd_bounce(struct vmw_sw_context *sw_context, (sw_context->cmd_bounce_size >> 1)); } -if (sw_context->cmd_bounce !=NULL ) -vfree (sw_context->cmd_bounce); - +vfree (sw_context->cmd_bounce); sw_context->cmd_bounce =vmalloc (sw_context->cmd_bounce_size);if (sw_context->cmd_bounce ==NULL ) {
Signature · 1 line
2.9.2
PATCH 1/1 drm/qxl: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 14:14:54 +0200
The drm_gem_object_unreference_unlocked() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/qxl/qxl_display.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/qxl/qxl_display.c +1 -2
@@ -468,8 +468,7 @@ void qxl_user_framebuffer_destroy(struct drm_framebuffer *fb) {struct qxl_framebuffer *qxl_fb =to_qxl_framebuffer (fb); -if (qxl_fb->obj) -drm_gem_object_unreference_unlocked (qxl_fb->obj); +drm_gem_object_unreference_unlocked (qxl_fb->obj);drm_framebuffer_cleanup (fb);kfree (qxl_fb); }
Signature · 1 line
2.9.2
PATCH 1/1 drm/bridge: ps8622: Delete an unnecessary check before backlight_device_unregister()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 14:45:51 +0200
The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/bridge/parade-ps8622.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/bridge/parade-ps8622.c +1 -3
@@ -636,9 +636,7 @@ static int ps8622_remove(struct i2c_client *client) {struct ps8622_bridge *ps8622 =i2c_get_clientdata (client); -if (ps8622->bl) -backlight_device_unregister (ps8622->bl); - +backlight_device_unregister (ps8622->bl);drm_bridge_remove (&ps8622->bridge);return 0 ;
Signature · 1 line
2.9.2
Sean Paul
AppliedRe: [PATCH] drm/mgag200: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 11:20:27 +0200The
drm_gem_object_unreference_unlocked()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied to drm-misc
Quoted 26 lines
--- drivers/gpu/drm/mgag200/mgag200_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/mgag200/mgag200_main.c +2
-3@@ -17,8 +17,8 @@static void mga_user_framebuffer_destroy (struct drm_framebuffer *fb) {struct mga_framebuffer *mga_fb =to_mga_framebuffer (fb); -if (mga_fb->obj) -drm_gem_object_unreference_unlocked (mga_fb->obj); + +drm_gem_object_unreference_unlocked (mga_fb->obj);drm_framebuffer_cleanup (fb);kfree (fb); } --2.9.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sean Paul
AppliedRe: [PATCH] drm/vmwgfx: Delete an unnecessary check before the function call "vfree"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 13:31:00 +0200The
vfree()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied to drm-misc
Quoted 26 lines
--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +1
-4@@ -3625,9 +3625,7 @@ static int vmw_resize_cmd_bounce(struct vmw_sw_context *sw_context, (sw_context->cmd_bounce_size >> 1)); } -if (sw_context->cmd_bounce !=NULL ) -vfree (sw_context->cmd_bounce); - +vfree (sw_context->cmd_bounce); sw_context->cmd_bounce =vmalloc (sw_context->cmd_bounce_size);if (sw_context->cmd_bounce ==NULL ) { --2.9.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sean Paul
AppliedRe: [PATCH] drm/qxl: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 14:14:54 +0200The
drm_gem_object_unreference_unlocked()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied to drm-misc
Quoted 25 lines
--- drivers/gpu/drm/qxl/qxl_display.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpu/drm/qxl/qxl_display.c +1
-3@@ -468,8 +468,7 @@ void qxl_user_framebuffer_destroy(struct drm_framebuffer *fb) {struct qxl_framebuffer *qxl_fb =to_qxl_framebuffer (fb); -if (qxl_fb->obj) -drm_gem_object_unreference_unlocked (qxl_fb->obj); +drm_gem_object_unreference_unlocked (qxl_fb->obj);drm_framebuffer_cleanup (fb);kfree (qxl_fb); } --2.9.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sean Paul
AppliedRe: [PATCH] drm/bridge: ps8622: Delete an unnecessary check before backlight_device_unregister()
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 14:45:51 +0200The
backlight_device_unregister()function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied to drm-misc
Quoted 26 lines
--- drivers/gpu/drm/bridge/parade-ps8622.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/gpu/drm/bridge/parade-ps8622.c +1
-4@@ -636,9 +636,7 @@ static int ps8622_remove(struct i2c_client *client) {struct ps8622_bridge *ps8622 =i2c_get_clientdata (client); -if (ps8622->bl) -backlight_device_unregister (ps8622->bl); - +backlight_device_unregister (ps8622->bl);drm_bridge_remove (&ps8622->bridge);return 0 ; --2.9.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Rich Felker
maintainerRe: [PATCH] sh-DWARF: Delete unnecessary checks before the function call "mempool_destroy"
In reply to SF Markus ElfringQuoted 21 lines · SF Markus Elfring
Quoted 21 lines
From: Markus Elfring <[email protected]>
Date: Mon, 16 Nov 2015 08:20:36 +0100The
mempool_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- arch/sh/kernel/dwarf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)arch/sh/kernel/dwarf.c +0
-0@@ -1009,10 +1009,8 @@ static void __init dwarf_unwinder_cleanup(void)rbtree_postorder_for_each_entry_safe (cie, next_cie, &cie_root, node)kfree (cie);
Quoted 13 lines
arch/sh/kernel/dwarf.c static void __init dwarf_unwinder_cleanup(void) · line 1016
Quoted 10 lines
arch/sh/kernel/dwarf.c +2
-4-if (dwarf_reg_pool) -mempool_destroy (dwarf_reg_pool); -if (dwarf_frame_pool) -mempool_destroy (dwarf_frame_pool); +mempool_destroy (dwarf_reg_pool); +mempool_destroy (dwarf_frame_pool);kmem_cache_destroy (dwarf_reg_cachep);kmem_cache_destroy (dwarf_frame_cachep); }Would you like to integrate this update suggestion into another source code repository?
Looks OK. I have it in my linux-sh tree to go upstream.
Rich
Re: [PATCH] drm/vmwgfx: Delete an unnecessary check before the function call "vfree"
In reply to SF Markus ElfringLooks good. Thanks!
Quoted 31 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 13:31:00 +0200The
vfree()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +1
-3@@ -3625,9 +3625,7 @@ static int vmw_resize_cmd_bounce(struct vmw_sw_context *sw_context, (sw_context->cmd_bounce_size >> 1)); } -if (sw_context->cmd_bounce !=NULL ) -vfree (sw_context->cmd_bounce); - +vfree (sw_context->cmd_bounce); sw_context->cmd_bounce =vmalloc (sw_context->cmd_bounce_size);if (sw_context->cmd_bounce ==NULL ) {Signature · 1 line
2.9.2
cover GPU-DRM-Etnaviv: Fine-tuning for a few functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 17:34:32 +0200
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (4):
Delete unnecessary checks before two function calls Delete unnecessary if statement in __etnaviv_gem_new() Rename jump labels
Optimize error handling in etnaviv_gem_new_userptr()
drivers/gpu/drm/etnaviv/etnaviv_gem.c | 36 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 23 deletions(-)
Signature · 1 line
2.9.2
PATCH 1/4 GPU-DRM-Etnaviv: Delete unnecessary checks before two function calls
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 15:56:15 +0200
The functions drm_gem_object_unreference_unlocked() and vunmap() perform also input parameter validation.
Thus the tests around their calls are not needed.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gem.c +2 -5
@@ -535,8 +535,7 @@ void etnaviv_gem_describe_objects(struct etnaviv_drm_private *priv,static void etnaviv_gem_shmem_release (struct etnaviv_gem_object *etnaviv_obj) { -if (etnaviv_obj->vaddr) -vunmap (etnaviv_obj->vaddr); +vunmap (etnaviv_obj->vaddr);put_pages (etnaviv_obj); }
@@ -670,9 +669,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,return obj; fail: -if (obj) -drm_gem_object_unreference_unlocked (obj); - +drm_gem_object_unreference_unlocked (obj);return ERR_PTR (ret); }
Signature · 1 line
2.9.2
PATCH 2/4 GPU-DRM-Etnaviv: Delete unnecessary if statement in __etnaviv_gem_new()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 16:45:22 +0200
Move a return statement into a block for successful function execution. Omit a duplicate check for the local variable "ret" then at the end.
--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gem.c +1 -5
@@ -661,13 +661,9 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,*/ mapping = obj->filp->f_mapping;mapping_set_gfp_mask (mapping,GFP_HIGHUSER ); +return obj; } -if (ret) - goto fail; - -return obj; - fail:drm_gem_object_unreference_unlocked (obj);return ERR_PTR (ret);
Signature · 1 line
2.9.2
PATCH 3/4 GPU-DRM-Etnaviv: Rename jump labels
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 16:51:00 +0200
Adjust jump targets according to the Linux coding style convention.
--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gem.c +7 -7
@@ -308,17 +308,17 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get( mapping =NULL ;mutex_unlock (&gpu->mmu->lock);if (mapping) - goto out; + goto unlock; }else { mapping->use +=1 ; - goto out; + goto unlock; } } pages =etnaviv_gem_get_pages (etnaviv_obj);if (IS_ERR (pages)) { ret =PTR_ERR (pages); - goto out; + goto unlock; }/*
@@ -330,7 +330,7 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get( mapping =kzalloc (sizeof (*mapping),GFP_KERNEL );if (!mapping) { ret = -ENOMEM ; - goto out; + goto unlock; }INIT_LIST_HEAD (&mapping->scan_node);
@@ -349,7 +349,7 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get(else list_add_tail (&mapping->obj_node, &etnaviv_obj->vram_list); -out: +unlock:mutex_unlock (&etnaviv_obj->lock);if (ret)
@@ -646,7 +646,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev, ret =etnaviv_gem_new_impl (dev, size, flags,NULL , &etnaviv_gem_shmem_ops, &obj);if (ret) - goto fail; + goto unreference; ret =drm_gem_object_init (dev, obj, size);if (ret ==0 ) {
@@ -664,7 +664,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,return obj; } -fail: +unreference:drm_gem_object_unreference_unlocked (obj);return ERR_PTR (ret); }
Signature · 1 line
2.9.2
PATCH 4/4 GPU-DRM-Etnaviv: Optimize error handling in etnaviv_gem_new_userptr()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 17:17:48 +0200
Refactor this function implementation so that the drm_gem_object_unreference_unlocked() function will only be called once in case of a failure according to the Linux coding style recommendation for centralized exiting of functions.
--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gem.c +3 -6
@@ -909,15 +909,12 @@ int etnaviv_gem_new_userptr(struct drm_device *dev, struct drm_file *file,get_task_struct (current); ret =etnaviv_gem_obj_add (dev, &etnaviv_obj->base); -if (ret) { -drm_gem_object_unreference_unlocked (&etnaviv_obj->base); -return ret; - } +if (ret) + goto unreference; ret =drm_gem_handle_create (file, &etnaviv_obj->base, handle); - +unreference:/* drop reference from allocate - handle holds it now */ drm_gem_object_unreference_unlocked (&etnaviv_obj->base); -return ret; }
Signature · 1 line
2.9.2
Re: [PATCH 2/4] GPU-DRM-Etnaviv: Delete unnecessary if statement in __etnaviv_gem_new()
In reply to SF Markus ElfringAm 22.07.2016 17:48, schrieb SF Markus Elfring:
Quoted 32 lines
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 16:45:22 +0200Move a return statement into a block for successful function execution. Omit a duplicate check for the local variable "ret" then at the end.
Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/gpu/drm/etnaviv/etnaviv_gem.c +1
-5@@ -661,13 +661,9 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,*/ mapping = obj->filp->f_mapping;mapping_set_gfp_mask (mapping,GFP_HIGHUSER ); +return obj; } -if (ret) - goto fail; - -return obj; - fail:drm_gem_object_unreference_unlocked (obj);return ERR_PTR (ret);
Quoted 1 line
From the program flow an readability it would be more nice the branch on error
ret = drm_gem_object_init(dev, obj, size);
if (ret)
goto fail;
just m 2 cents
re,
wh
PATCH 1/1 ASoC: Intel: Skylake: Delete an unnecessary check before the function call "release_firmware"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 18:58:14 +0200
The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- sound/soc/intel/skylake/skl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/intel/skylake/skl.c +1 -2
@@ -781,8 +781,7 @@ static void skl_remove(struct pci_dev *pci)struct hdac_ext_bus *ebus =pci_get_drvdata (pci);struct skl *skl =ebus_to_skl (ebus); -if (skl->tplg) -release_firmware (skl->tplg); +release_firmware (skl->tplg);if (pci_dev_run_wake (pci))pm_runtime_get_noresume (&pci->dev);
Signature · 1 line
2.9.2
PATCH 1/1 drm/etnaviv: Improve readability in __etnaviv_gem_new
In reply to walter harmsMove things around a little in __etnaviv_gem_new() to make it more readable.
--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gem.c +11 -14
@@ -640,6 +640,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev, u32 size, u32 flags) {struct drm_gem_object *obj =NULL ; +struct address_space *mapping;int ret; size =PAGE_ALIGN (size);
@@ -650,23 +651,19 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev, goto fail; ret =drm_gem_object_init (dev, obj, size); -if (ret ==0 ) { -struct address_space *mapping; - -/* -* Our buffers are kept pinned, so allocating them -* from the MOVABLE zone is a really bad idea, and -* conflicts with CMA. See coments above new_inode() -* why this is required _and_ expected if you're -* going to pin these pages. -*/ - mapping =file_inode (obj->filp)->i_mapping; -mapping_set_gfp_mask (mapping,GFP_HIGHUSER ); - } -if (ret) goto fail; +/* +* Our buffers are kept pinned, so allocating them +* from the MOVABLE zone is a really bad idea, and +* conflicts with CMA. See coments above new_inode() +* why this is required _and_ expected if you're +* going to pin these pages. +*/ + mapping =file_inode (obj->filp)->i_mapping; +mapping_set_gfp_mask (mapping,GFP_HIGHUSER ); +return obj; fail:
Signature · 1 line
2.8.0.rc3.226.g39d4020
Re: [PATCH 3/4] GPU-DRM-Etnaviv: Rename jump labels
In reply to SF Markus ElfringQuoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 16:51:00 +0200Adjust jump targets according to the Linux coding style convention.
I'm not convinced the old labels are really that bad, tbh.
Sean
Quoted 73 lines
Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/gpu/drm/etnaviv/etnaviv_gem.c +7
-8@@ -308,17 +308,17 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get( mapping =NULL ;mutex_unlock (&gpu->mmu->lock);if (mapping) - goto out; + goto unlock; }else { mapping->use +=1 ; - goto out; + goto unlock; } } pages =etnaviv_gem_get_pages (etnaviv_obj);if (IS_ERR (pages)) { ret =PTR_ERR (pages); - goto out; + goto unlock; }/* @@ -330,7 +330,7 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get( mapping =kzalloc (sizeof (*mapping),GFP_KERNEL );if (!mapping) { ret = -ENOMEM ; - goto out; + goto unlock; }INIT_LIST_HEAD (&mapping->scan_node);@@ -349,7 +349,7 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get(else list_add_tail (&mapping->obj_node, &etnaviv_obj->vram_list); -out: +unlock:mutex_unlock (&etnaviv_obj->lock);if (ret)@@ -646,7 +646,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev, ret =etnaviv_gem_new_impl (dev, size, flags,NULL , &etnaviv_gem_shmem_ops, &obj);if (ret) - goto fail; + goto unreference; ret =drm_gem_object_init (dev, obj, size);if (ret =0 ) {@@ -664,7 +664,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,return obj; } -fail: +unreference:drm_gem_object_unreference_unlocked (obj);return ERR_PTR (ret); } --2.9.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sean Paul
AppliedRe: [PATCH 1/4] GPU-DRM-Etnaviv: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 15:56:15 +0200The functions
drm_gem_object_unreference_unlocked()andvunmap()perform also input parameter validation.
Thus the tests around their calls are not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied to drm-misc. In the future, could you please format your subjects starting with "drm/<driver>"? I've fixed this one and the next, but it'd be nice not to have to do that going forward.
Quoted 36 lines
--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/gpu/drm/etnaviv/etnaviv_gem.c +2
-6@@ -535,8 +535,7 @@ void etnaviv_gem_describe_objects(struct etnaviv_drm_private *priv,static void etnaviv_gem_shmem_release (struct etnaviv_gem_object *etnaviv_obj) { -if (etnaviv_obj->vaddr) -vunmap (etnaviv_obj->vaddr); +vunmap (etnaviv_obj->vaddr);put_pages (etnaviv_obj); }@@ -670,9 +669,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,return obj; fail: -if (obj) -drm_gem_object_unreference_unlocked (obj); - +drm_gem_object_unreference_unlocked (obj);return ERR_PTR (ret); } --2.9.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sean Paul
AppliedRe: [PATCH 4/4] GPU-DRM-Etnaviv: Optimize error handling in etnaviv_gem_new_userptr()
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 17:17:48 +0200Refactor this function implementation so that the
drm_gem_object_unreference_unlocked()function will only be called once in case of a failure according to the Linux coding style recommendation for centralized exiting of functions.Signed-off-by Markus Elfring <[email protected]>
Applied to drm-misc. In the future, could you please format your subjects starting with "drm/<driver>"? I've fixed this one and the first, but it'd be nice not to have to do that going forward.
Sean
Quoted 34 lines
--- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/gpu/drm/etnaviv/etnaviv_gem.c +3
-7@@ -909,15 +909,12 @@ int etnaviv_gem_new_userptr(struct drm_device *dev, struct drm_file *file,get_task_struct (current); ret =etnaviv_gem_obj_add (dev, &etnaviv_obj->base); -if (ret) { -drm_gem_object_unreference_unlocked (&etnaviv_obj->base); -return ret; - } +if (ret) + goto unreference; ret =drm_gem_handle_create (file, &etnaviv_obj->base, handle); - +unreference:/* drop reference from allocate - handle holds it now */ drm_gem_object_unreference_unlocked (&etnaviv_obj->base); -return ret; } --2.9.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/1 zsmalloc: Delete an unnecessary check before the function call "iput"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 19:54:20 +0200
The iput() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- mm/zsmalloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
mm/zsmalloc.c +1 -2
@@ -2181,8 +2181,7 @@ static int zs_register_migration(struct zs_pool *pool)static void zs_unregister_migration (struct zs_pool *pool) {flush_work (&pool->free_work); -if (pool->inode) -iput (pool->inode); +iput (pool->inode); }/*
Signature · 1 line
2.9.2
PATCH 1/1 block: Delete an unnecessary check before the function call "kmem_cache_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 21:07:37 +0200
The kmem_cache_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- block/elevator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
block/elevator.c +1 -2
@@ -846,8 +846,7 @@ int elv_register(struct elevator_type *e)spin_lock (&elv_list_lock);if (elevator_find (e->elevator_name)) {spin_unlock (&elv_list_lock); -if (e->icq_cache) -kmem_cache_destroy (e->icq_cache); +kmem_cache_destroy (e->icq_cache);return -EBUSY ; }list_add_tail (&e->list, &elv_list);
Signature · 1 line
2.9.2
PATCH 1/1 block: Delete unnecessary checks before the function call "mempool_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 21:45:26 +0200
The mempool_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- block/bio-integrity.c | 7 ++----- block/bio.c | 8 ++------ block/blk-core.c | 3 +-- 3 files changed, 5 insertions(+), 13 deletions(-)
block/bio-integrity.c +2 -5
@@ -499,11 +499,8 @@ EXPORT_SYMBOL(bioset_integrity_create);void bioset_integrity_free (struct bio_set *bs) { -if (bs->bio_integrity_pool) -mempool_destroy (bs->bio_integrity_pool); - -if (bs->bvec_integrity_pool) -mempool_destroy (bs->bvec_integrity_pool); +mempool_destroy (bs->bio_integrity_pool); +mempool_destroy (bs->bvec_integrity_pool); }EXPORT_SYMBOL (bioset_integrity_free);
block/bio.c +2 -6
@@ -1843,12 +1843,8 @@ void bioset_free(struct bio_set *bs)if (bs->rescue_workqueue)destroy_workqueue (bs->rescue_workqueue); -if (bs->bio_pool) -mempool_destroy (bs->bio_pool); - -if (bs->bvec_pool) -mempool_destroy (bs->bvec_pool); - +mempool_destroy (bs->bio_pool); +mempool_destroy (bs->bvec_pool);bioset_integrity_free (bs);bio_put_slab (bs);
block/blk-core.c +1 -2
@@ -636,8 +636,7 @@ int blk_init_rl(struct request_list *rl, struct request_queue *q,void blk_exit_rl (struct request_list *rl) { -if (rl->rq_pool) -mempool_destroy (rl->rq_pool); +mempool_destroy (rl->rq_pool); }struct request_queue *blk_alloc_queue (gfp_t gfp_mask)
Signature · 1 line
2.9.2
Re: [PATCH] PM-wakeup: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringAm 28.06.2015 um 12:21 schrieb SF Markus Elfring:
Quoted 40 lines
From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 12:14:43 +0200The functions
dev_pm_disarm_wake_irq()andwakeup_source_unregister()test whether their argument is NULL and then return immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/base/power/wakeup.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)drivers/base/power/wakeup.c +2
-4@@ -341,8 +341,7 @@ void device_wakeup_arm_wake_irqs(void)rcu_read_lock ();list_for_each_entry_rcu (ws, &wakeup_sources, entry) { -if (ws->wakeirq) -dev_pm_arm_wake_irq (ws->wakeirq); +dev_pm_arm_wake_irq (ws->wakeirq); }rcu_read_unlock (); }@@ -358,8 +357,7 @@ void device_wakeup_disarm_wake_irqs(void)rcu_read_lock ();list_for_each_entry_rcu (ws, &wakeup_sources, entry) { -if (ws->wakeirq) -dev_pm_disarm_wake_irq (ws->wakeirq); +dev_pm_disarm_wake_irq (ws->wakeirq); }rcu_read_unlock (); }
drivers/base/power/wakeup.c int device_wakeup_disable(struct device *dev) · line 400
Quoted 10 lines
drivers/base/power/wakeup.c +1
-3@@ -396,9 +394,7 @@ int device_wakeup_disable(struct device *dev)return -EINVAL ; ws =device_wakeup_detach (dev); -if (ws) -wakeup_source_unregister (ws); - +wakeup_source_unregister (ws);return 0 ; }EXPORT_SYMBOL_GPL (device_wakeup_disable);
How do you think about to integrate this update suggestion into another source code repository?
Regards,
Markus
Re: [PATCH] PM-wakeup: Delete unnecessary checks before two function calls
Quoted 42 lines · SF Markus Elfring
Am 28.06.2015 um 12:21 schrieb SF Markus Elfring:
Quoted 41 lines
From: Markus Elfring <[email protected]>
Date: Sun, 28 Jun 2015 12:14:43 +0200The functions
dev_pm_disarm_wake_irq()andwakeup_source_unregister()test whether their argument is NULL and then return immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/base/power/wakeup.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)drivers/base/power/wakeup.c +2
-4@@ -341,8 +341,7 @@ void device_wakeup_arm_wake_irqs(void)rcu_read_lock ();list_for_each_entry_rcu (ws, &wakeup_sources, entry) { -if (ws->wakeirq) -dev_pm_arm_wake_irq (ws->wakeirq); +dev_pm_arm_wake_irq (ws->wakeirq); }rcu_read_unlock (); }@@ -358,8 +357,7 @@ void device_wakeup_disarm_wake_irqs(void)rcu_read_lock ();list_for_each_entry_rcu (ws, &wakeup_sources, entry) { -if (ws->wakeirq) -dev_pm_disarm_wake_irq (ws->wakeirq); +dev_pm_disarm_wake_irq (ws->wakeirq); }rcu_read_unlock (); }@@ -396,9 +394,7 @@ int device_wakeup_disable(struct device *dev)return -EINVAL ;
Quoted 12 lines
drivers/base/power/wakeup.c int device_wakeup_disable(struct device *dev) · line 400
Quoted 9 lines
drivers/base/power/wakeup.c +1
-3ws =device_wakeup_detach (dev); -if (ws) -wakeup_source_unregister (ws); - +wakeup_source_unregister (ws);return 0 ; }EXPORT_SYMBOL_GPL (device_wakeup_disable);How do you think about to integrate this update suggestion into another source code repository?
I'm not really sure what you mean.
Thanks,
Rafael
Re: PM-wakeup: Delete unnecessary checks before two function calls
Quoted 4 lines
Quoted 2 lines
How do you think about to integrate this update suggestion into another source code repository?
I'm not really sure what you mean.
Do you find the suggested source code change acceptable?
http://article.gmane.org/gmane.linux.power-management.general/61766
https://lkml.org/lkml/2015/6/28/21
Who would dare to commit it?
Regards,
Markus
PATCH 1/1 IB/hfi1: Delete an unnecessary check before the function call "sc_return_credits"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 08:30:52 +0200
The sc_return_credits() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/infiniband/hw/hfi1/file_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/hfi1/file_ops.c +1 -1
@@ -228,7 +228,7 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd, sizeof(struct hfi1_base_info));break ;case HFI1_IOCTL_CREDIT_UPD : -if (uctxt && uctxt->sc) +if (uctxt)sc_return_credits (uctxt->sc);break ;
Signature · 1 line
2.9.2
cover IB/mthca: Fine-tuning for mthca_reset()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 12:50:12 +0200
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (3):
Delete an unnecessary check before the function call "pci_dev_put" Less function calls after error detection
Delete unnecessary variable initialisations
drivers/infiniband/hw/mthca/mthca_reset.c | 48 +++++++++++++++---------------- 1 file changed, 23 insertions(+), 25 deletions(-)
Signature · 1 line
2.9.2
PATCH 1/3 IB/mthca: Delete an unnecessary check before the function call "pci_dev_put"
From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 10:05:12 +0200
The pci_dev_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/infiniband/hw/mthca/mthca_reset.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/mthca/mthca_reset.c +1 -2
@@ -279,8 +279,7 @@ good: } out: -if (bridge) -pci_dev_put (bridge); +pci_dev_put (bridge);kfree (bridge_header);kfree (hca_header);
Signature · 1 line
2.9.2
PATCH 2/3 IB/mthca: Less function calls in mthca_reset() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 11:28:30 +0200
The kfree() function was called in a few cases by the mthca_reset() function during error handling even if the passed variables "bridge_header" and "hca_header" contained a null pointer.
Adjust jump targets according to the Linux coding style convention.
--- drivers/infiniband/hw/mthca/mthca_reset.c | 41 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 21 deletions(-)
drivers/infiniband/hw/mthca/mthca_reset.c +20 -21
@@ -98,7 +98,7 @@ int mthca_reset(struct mthca_dev *mdev) err = -ENOMEM ;mthca_err (mdev,"Couldn't allocate memory to save HCA " "PCI header, aborting.\n" ); - goto out; + goto put_dev; }for (i =0 ; i <64 ; ++i) {
@@ -108,7 +108,7 @@ int mthca_reset(struct mthca_dev *mdev) err = -ENODEV ;mthca_err (mdev,"Couldn't save HCA " "PCI header, aborting.\n" ); - goto out; + goto free_hca; } }
@@ -121,7 +121,7 @@ int mthca_reset(struct mthca_dev *mdev) err = -ENOMEM ;mthca_err (mdev,"Couldn't allocate memory to save HCA " "bridge PCI header, aborting.\n" ); - goto out; + goto free_hca; }for (i =0 ; i <64 ; ++i) {
@@ -131,7 +131,7 @@ int mthca_reset(struct mthca_dev *mdev) err = -ENODEV ;mthca_err (mdev,"Couldn't save HCA bridge " "PCI header, aborting.\n" ); - goto out; + goto free_bh; } } bridge_pcix_cap =pci_find_capability (bridge,PCI_CAP_ID_PCIX );
@@ -139,7 +139,7 @@ int mthca_reset(struct mthca_dev *mdev) err = -ENODEV ;mthca_err (mdev,"Couldn't locate HCA bridge " "PCI-X capability, aborting.\n" ); - goto out; + goto free_bh; } }
@@ -152,7 +152,7 @@ int mthca_reset(struct mthca_dev *mdev) err = -ENOMEM ;mthca_err (mdev,"Couldn't map HCA reset register, " "aborting.\n" ); - goto out; + goto free_bh; }writel (MTHCA_RESET_VALUE , reset);
@@ -172,7 +172,7 @@ int mthca_reset(struct mthca_dev *mdev) err = -ENODEV ;mthca_err (mdev,"Couldn't access HCA after reset, " "aborting.\n" ); - goto out; + goto free_bh; }if (v !=0xffffffff )
@@ -184,7 +184,7 @@ int mthca_reset(struct mthca_dev *mdev) err = -ENODEV ;mthca_err (mdev,"PCI device did not come back after reset, " "aborting.\n" ); - goto out; + goto free_bh; } good:
@@ -195,14 +195,14 @@ good: err = -ENODEV ;mthca_err (mdev,"Couldn't restore HCA bridge Upstream " "split transaction control, aborting.\n" ); - goto out; + goto free_bh; }if (pci_write_config_dword (bridge, bridge_pcix_cap +0xc , bridge_header[(bridge_pcix_cap +0xc ) /4 ])) { err = -ENODEV ;mthca_err (mdev,"Couldn't restore HCA bridge Downstream " "split transaction control, aborting.\n" ); - goto out; + goto free_bh; }/* * Bridge control register is at 0x3e, so we'll
@@ -216,7 +216,7 @@ good: err = -ENODEV ;mthca_err (mdev,"Couldn't restore HCA bridge reg %x, " "aborting.\n" , i); - goto out; + goto free_bh; } }
@@ -225,7 +225,7 @@ good: err = -ENODEV ;mthca_err (mdev,"Couldn't restore HCA bridge COMMAND, " "aborting.\n" ); - goto out; + goto free_bh; } }
@@ -235,7 +235,7 @@ good: err = -ENODEV ;mthca_err (mdev,"Couldn't restore HCA PCI-X " "command register, aborting.\n" ); - goto out; + goto free_bh; } }
@@ -246,7 +246,7 @@ good: err = -ENODEV ;mthca_err (mdev,"Couldn't restore HCA PCI Express " "Device Control register, aborting.\n" ); - goto out; + goto free_bh; } linkctl = hca_header[(hca_pcie_cap +PCI_EXP_LNKCTL ) /4 ]; if (pcie_capability_write_word(mdev->pdev, PCI_EXP_LNKCTL,
@@ -254,7 +254,7 @@ good: err = -ENODEV ;mthca_err (mdev,"Couldn't restore HCA PCI Express " "Link control register, aborting.\n" ); - goto out; + goto free_bh; } }
@@ -266,7 +266,7 @@ good: err = -ENODEV ;mthca_err (mdev,"Couldn't restore HCA reg %x, " "aborting.\n" , i); - goto out; + goto free_bh; } }
@@ -275,13 +275,12 @@ good: err = -ENODEV ;mthca_err (mdev,"Couldn't restore HCA COMMAND, " "aborting.\n" ); - goto out; } - -out: -pci_dev_put (bridge); +free_bh:kfree (bridge_header); +free_hca:kfree (hca_header); - +put_dev: +pci_dev_put (bridge);return err; }
Signature · 1 line
2.9.2
PATCH 3/3 IB/mthca: Delete unnecessary variable initialisations in mthca_reset()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 11:54:06 +0200
Three local variables will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.
--- drivers/infiniband/hw/mthca/mthca_reset.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/hw/mthca/mthca_reset.c +3 -3
@@ -42,12 +42,12 @@ int mthca_reset(struct mthca_dev *mdev) {int i;int err =0 ; -u32 *hca_header =NULL ; +u32 *hca_header;u32 *bridge_header =NULL ;struct pci_dev *bridge =NULL ;int bridge_pcix_cap =0 ; -int hca_pcie_cap =0 ; -int hca_pcix_cap =0 ; +int hca_pcie_cap; +int hca_pcix_cap;u16 devctl;u16 linkctl;
Signature · 1 line
2.9.2
Re: PM-wakeup: Delete unnecessary checks before two function calls
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines
How do you think about to integrate this update suggestion into another source code repository?
I'm not really sure what you mean.
Do you find the suggested source code change acceptable?
http://article.gmane.org/gmane.linux.power-management.general/61766
https://lkml.org/lkml/2015/6/28/21
Yes, it is acceptable, but you also should remove some braces that aren't necessary any more.
Thanks,
Rafael
PATCH 1/1 power: generic-adc-battery: Delete unnecessary checks before the function call "iio_channel_release"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 14:50:47 +0200
The iio_channel_release() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/power/generic-adc-battery.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/power/generic-adc-battery.c +4 -9
@@ -350,10 +350,8 @@ err_gpio: gpio_req_fail:power_supply_unregister (adc_bat->psy); err_reg_fail: -for (chan =0 ; chan <ARRAY_SIZE (gab_chan_name); chan++) { -if (adc_bat->channel[chan]) -iio_channel_release (adc_bat->channel[chan]); - } +for (chan =0 ; chan <ARRAY_SIZE (gab_chan_name); chan++) +iio_channel_release (adc_bat->channel[chan]); second_mem_fail:kfree (psy_desc->properties); first_mem_fail:
@@ -373,11 +371,8 @@ static int gab_remove(struct platform_device *pdev)gpio_free (pdata->gpio_charge_finished); } -for (chan =0 ; chan <ARRAY_SIZE (gab_chan_name); chan++) { -if (adc_bat->channel[chan]) -iio_channel_release (adc_bat->channel[chan]); - } - +for (chan =0 ; chan <ARRAY_SIZE (gab_chan_name); chan++) +iio_channel_release (adc_bat->channel[chan]);kfree (adc_bat->psy_desc.properties);cancel_delayed_work (&adc_bat->bat_work);return 0 ;
Signature · 1 line
2.9.2
PATCH 1/1 PM-wakeup: Delete unnecessary checks before three function calls
In reply to Rafael J. WysockiFrom: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 17:04:00 +0200
The following functions test whether their argument is NULL and then return immediately.
* dev_pm_arm_wake_irq
* dev_pm_disarm_wake_irq
* wakeup_source_unregister
Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/base/power/wakeup.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/base/power/wakeup.c +5 -11
@@ -334,10 +334,8 @@ void device_wakeup_arm_wake_irqs(void)struct wakeup_source *ws;rcu_read_lock (); -list_for_each_entry_rcu (ws, &wakeup_sources, entry) { -if (ws->wakeirq) -dev_pm_arm_wake_irq (ws->wakeirq); - } +list_for_each_entry_rcu (ws, &wakeup_sources, entry) +dev_pm_arm_wake_irq (ws->wakeirq);rcu_read_unlock (); }
@@ -351,10 +349,8 @@ void device_wakeup_disarm_wake_irqs(void)struct wakeup_source *ws;rcu_read_lock (); -list_for_each_entry_rcu (ws, &wakeup_sources, entry) { -if (ws->wakeirq) -dev_pm_disarm_wake_irq (ws->wakeirq); - } +list_for_each_entry_rcu (ws, &wakeup_sources, entry) +dev_pm_disarm_wake_irq (ws->wakeirq);rcu_read_unlock (); }
@@ -390,9 +386,7 @@ int device_wakeup_disable(struct device *dev)return -EINVAL ; ws =device_wakeup_detach (dev); -if (ws) -wakeup_source_unregister (ws); - +wakeup_source_unregister (ws);return 0 ; }EXPORT_SYMBOL_GPL (device_wakeup_disable);
Signature · 1 line
2.9.2
PATCH 1/1 memory: omap-gpmc: Delete an unnecessary check before the function call "gpiochip_free_own_desc"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 18:54:02 +0200
The gpiochip_free_own_desc() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/memory/omap-gpmc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/memory/omap-gpmc.c +1 -3
@@ -2143,9 +2143,7 @@ err_child_fail: ret = -ENODEV ; err_cs: -if (waitpin_desc) -gpiochip_free_own_desc (waitpin_desc); - +gpiochip_free_own_desc (waitpin_desc); err:gpmc_cs_free (cs);
Signature · 1 line
2.9.2
PATCH 1/1 omapfb: panel-dsi-cm: Delete an unnecessary check before backlight_device_unregister()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 19:29:28 +0200
The backlight_device_unregister() function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c +1 -2
@@ -1283,8 +1283,7 @@ static int dsicm_probe(struct platform_device *pdev)return 0 ; err_sysfs_create: -if (bldev !=NULL ) -backlight_device_unregister (bldev); +backlight_device_unregister (bldev); err_bl:destroy_workqueue (ddata->workqueue); err_reg:
Signature · 1 line
2.9.2
PATCH 1/1 coresight: tmc: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 20:04:09 +0200
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-tmc-etf.c +1 -1
@@ -168,7 +168,7 @@ out:spin_unlock_irqrestore (&drvdata->spinlock, flags);/* Free memory outside the spinlock if need be */ -if (!used && buf) +if (!used)kfree (buf);if (!ret)
Signature · 1 line
2.9.2
PATCH 1/1 Input-rmi_bus: Delete an unnecessary check before the function call "of_node_put"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 07:37:23 +0200
The of_node_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/input/rmi4/rmi_bus.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/input/rmi4/rmi_bus.c +1 -4
@@ -232,10 +232,7 @@ err_put_device:void rmi_unregister_function (struct rmi_function *fn) {device_del (&fn->dev); - -if (fn->dev.of_node) -of_node_put (fn->dev.of_node); - +of_node_put (fn->dev.of_node);put_device (&fn->dev); }
Signature · 1 line
2.9.2
PATCH 1/1 firmware-gsmi: Delete an unnecessary check before the function call "dma_pool_destroy"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 10:16:56 +0200
The dma_pool_destroy() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/firmware/google/gsmi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/firmware/google/gsmi.c +1 -2
@@ -910,8 +910,7 @@ out_err:gsmi_buf_free (gsmi_dev.param_buf);gsmi_buf_free (gsmi_dev.data_buf);gsmi_buf_free (gsmi_dev.name_buf); -if (gsmi_dev.dma_pool) -dma_pool_destroy (gsmi_dev.dma_pool); +dma_pool_destroy (gsmi_dev.dma_pool);platform_device_unregister (gsmi_dev.pdev);pr_info ("gsmi: failed to load: %d\n" , ret);return ret;
Signature · 1 line
2.9.2
PATCH 1/1 libnvdimm-btt: Delete an unnecessary check before the function call "__nd_device_register"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 11:05:34 +0200
The __nd_device_register() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/nvdimm/btt_devs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/nvdimm/btt_devs.c +1 -2
@@ -198,8 +198,7 @@ struct device *nd_btt_create(struct nd_region *nd_region) {struct device *dev =__nd_btt_create (nd_region,0 ,NULL ,NULL ); -if (dev) -__nd_device_register (dev); +__nd_device_register (dev);return dev; }
Signature · 1 line
2.9.2
Re: [PATCH] cdrom: Delete an unnecessary check before unregister_sysctl_table()
In reply to SF Markus ElfringQuoted 19 lines
From: Markus Elfring <[email protected]>
Date: Thu, 9 Jul 2015 09:52:24 +0200The
unregister_sysctl_table()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/cdrom/cdrom.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/cdrom/cdrom.c +0
-0
drivers/cdrom/cdrom.c static void cdrom_sysctl_register(void) · line 3704
Quoted 9 lines
drivers/cdrom/cdrom.c +1
-2@@ -3698,8 +3698,7 @@ static void cdrom_sysctl_register(void)static void cdrom_sysctl_unregister (void ) { -if (cdrom_sysctl_header) -unregister_sysctl_table (cdrom_sysctl_header); +unregister_sysctl_table (cdrom_sysctl_header); }#else /* CONFIG_SYSCTL */
How do you think about to integrate this update suggestion into another source code repository?
Regards,
Markus
Re: [PATCH] SCSI-aic94xx: Delete unnecessary checks before the function call "kmem_cache_destroy"
In reply to SF Markus ElfringQuoted 23 lines
From: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 08:14:52 +0100The
kmem_cache_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/scsi/aic94xx/aic94xx_init.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/scsi/aic94xx/aic94xx_init.c +0
-1@@ -660,12 +660,9 @@ Err:static void asd_destroy_global_caches (void ) { -if (asd_dma_token_cache)
drivers/scsi/aic94xx/aic94xx_init.c Err: · line 668
Quoted 10 lines
drivers/scsi/aic94xx/aic94xx_init.c +2
-4-kmem_cache_destroy (asd_dma_token_cache); +kmem_cache_destroy (asd_dma_token_cache); asd_dma_token_cache =NULL ; - -if (asd_ascb_cache) -kmem_cache_destroy (asd_ascb_cache); +kmem_cache_destroy (asd_ascb_cache); asd_ascb_cache =NULL ; }
How do you think about to integrate this update suggestion into another source code repository?
Regards,
Markus
PATCH 1/1 scsi: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 14:20:21 +0200
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/scsi/scsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/scsi.c +1 -2
@@ -864,8 +864,7 @@ retry_pg83:rcu_assign_pointer (sdev->vpd_pg83, vpd_buf);mutex_unlock (&sdev->inquiry_mutex);synchronize_rcu (); -if (orig_vpd_buf) -kfree (orig_vpd_buf); +kfree (orig_vpd_buf); } }
Signature · 1 line
2.9.2
Re: [PATCH] scsi: Delete an unnecessary check before the function call "kfree"
----- Original Message -----
Quoted 37 lines
From: "SF Markus Elfring" <[email protected]>
To: [email protected], "Christoph Hellwig" <[email protected]>, "Hannes Reinecke" <[email protected]>, "James E. J. Bottomley" <[email protected]>, "Martin K. Petersen" <[email protected]>
Cc: "LKML" <[email protected]>, [email protected], "Julia Lawall" <[email protected]>
Sent: Sunday, July 24, 2016 8:30:35 AM
Subject: [PATCH] scsi: Delete an unnecessary check before the function call "kfree"From: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 14:20:21 +0200The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/scsi/scsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/scsi/scsi.c +1
-3@@ -864,8 +864,7 @@ retry_pg83:rcu_assign_pointer (sdev->vpd_pg83, vpd_buf);mutex_unlock (&sdev->inquiry_mutex);synchronize_rcu (); -if (orig_vpd_buf) -kfree (orig_vpd_buf); +kfree (orig_vpd_buf); } } --2.9.2
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Looks fine, small comment is that the function call prior to check in the fucntion sets up variables etc. So is more expensive than a simple NULL check prior.
Dan Williams
AppliedRe: [PATCH] libnvdimm-btt: Delete an unnecessary check before the function call "__nd_device_register"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 11:05:34 +0200The
__nd_device_register()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Thanks, applied.
cover staging: wilc1000: Fine-tuning for two function implementations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (3):
Delete an unnecessary check before the function call "release_firmware" One function call less in mac_ioctl() after error detection Reduce scope for a few variables in mac_ioctl()
drivers/staging/wilc1000/linux_wlan.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
Signature · 1 line
2.9.2
PATCH 1/3 staging: wilc1000: Delete an unnecessary check before the function call "release_firmware"
From: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 21:00:20 +0200
The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/wilc1000/linux_wlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/wilc1000/linux_wlan.c +1 -1
@@ -1223,7 +1223,7 @@ void wilc_netdev_cleanup(struct wilc *wilc) vif[i] =netdev_priv (wilc->vif[i]->ndev); } -if (wilc && wilc->firmware) { +if (wilc) {release_firmware (wilc->firmware); wilc->firmware =NULL ; }
Signature · 1 line
2.9.2
PATCH 2/3 staging: wilc1000: One function call less in mac_ioctl() after error detection
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 21:15:23 +0200
The kfree() function was called in two cases by the mac_ioctl() function during error handling even if the passed variable did not contain a pointer for a valid data item.
Improve this implementation detail by the introduction of another jump label.
--- drivers/staging/wilc1000/linux_wlan.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/staging/wilc1000/linux_wlan.c +3 -5
@@ -1130,7 +1130,7 @@ static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)if (copy_to_user (wrq->u.data.pointer, buff, size)) {netdev_err (ndev,"failed to copy\n" ); ret = -EFAULT ; - goto done; + goto free_buffer; } } }
@@ -1144,11 +1144,9 @@ static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) goto done; } } - -done: - +free_buffer:kfree (buff); - +done:return ret; }
Signature · 1 line
2.9.2
PATCH 3/3 staging: wilc1000: Reduce scope for a few variables in mac_ioctl()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 21:45:37 +0200
Three local variables were used only within a single case branch.
* Thus move the data type definition for "rssi" and "size" into the corresponding code block.
* The variable "length" was not modified after its initialisation. Thus pass a constant value in the affected function call instead.
--- drivers/staging/wilc1000/linux_wlan.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/staging/wilc1000/linux_wlan.c +4 -5
@@ -1094,8 +1094,6 @@ int wilc_mac_close(struct net_device *ndev)static int mac_ioctl (struct net_device *ndev,struct ifreq *req,int cmd) {u8 *buff =NULL ; -s8 rssi; -u32 size =0 , length =0 ;struct wilc_vif *vif;s32 ret =0 ;struct wilc *wilc;
@@ -1110,8 +1108,7 @@ static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)case SIOCSIWPRIV : {struct iwreq *wrq = (struct iwreq *)req; - - size = wrq->u.data.length; +u32 size = wrq->u.data.length;if (size && wrq->u.data.pointer) { buff = memdup_user(wrq->u.data.pointer,
@@ -1119,7 +1116,9 @@ static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)if (IS_ERR (buff))return PTR_ERR (buff); -if (strncasecmp (buff,"RSSI" , length) =0 ) { +if (strncasecmp (buff,"RSSI" ,0 ) =0 ) { +s8 rssi; + ret =wilc_get_rssi (vif, &rssi);netdev_info (ndev,"RSSI :%d\n" , rssi);
Signature · 1 line
2.9.2
Mark Brown
maintainerApplied "ASoC: Intel: Skylake: Delete an unnecessary check before the function call "release_firmware"" to the asoc tree
In reply to SF Markus ElfringThe patch
ASoC: Intel: Skylake: Delete an unnecessary check before the function call "release_firmware"
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
1b00126cb3de017274e899ac559a744d4e3dbd61Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 18:58:14 +0200
Subject: [PATCH] ASoC: Intel: Skylake: Delete an unnecessary check before the
function call "release_firmware"
The release_firmware() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- sound/soc/intel/skylake/skl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/intel/skylake/skl.c +1 -2
@@ -781,8 +781,7 @@ static void skl_remove(struct pci_dev *pci)struct hdac_ext_bus *ebus =pci_get_drvdata (pci);struct skl *skl =ebus_to_skl (ebus); -if (skl->tplg) -release_firmware (skl->tplg); +release_firmware (skl->tplg);if (pci_dev_run_wake (pci))pm_runtime_get_noresume (&pci->dev);
Signature · 1 line
2.8.1
Re: [PATCH] zsmalloc: Delete an unnecessary check before the function call "iput"
In reply to SF Markus ElfringQuoted 4 lines · SF Markus Elfring
The
iput()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
there is no issue; the change is just cosmetic.
Quoted 1 line
Signed-off-by Markus Elfring <[email protected]>
alloc_anon_inode() returns ERR_PTR, so I'd probably rather change iput() to do IS_ERR_OR_NULL instead of !NULL.
inode = alloc_anon_inode();
if (IS_ERR(inode)) {
inode = NULL;
^^^^^^^^^^^^^
}
...
iput(inode);this NULL assignment on error path is a bit fragile.
IOW, something like this
---
fs/inode.c +1 -1
@@ -1497,7 +1497,7 @@ static void iput_final(struct inode *inode)*/ void iput (struct inode *inode) { -if (!inode) +if (IS_ERR_OR_NULL (inode))return ;BUG_ON (inode->i_state &I_CLEAR ); retry:
---
-ss
Quoted 21 lines
--- mm/zsmalloc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)mm/zsmalloc.c +1
-2@@ -2181,8 +2181,7 @@ static int zs_register_migration(struct zs_pool *pool)static void zs_unregister_migration (struct zs_pool *pool) {flush_work (&pool->free_work); -if (pool->inode) -iput (pool->inode); +iput (pool->inode); }/* Signature · 1 line
2.9.2
Re: [PATCH] GPU-DRM: Delete an unnecessary check before drm_property_unreference_blob()
In reply to SF Markus ElfringQuoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 12:48:12 +0200The
drm_property_unreference_blob()function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.
Quoted 7 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Quoted 16 lines
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +1
-3@@ -112,9 +112,7 @@ static void mtk_drm_crtc_reset(struct drm_crtc *crtc)struct mtk_crtc_state *state;if (crtc->state) { -if (crtc->state->mode_blob) -drm_property_unreference_blob (crtc->state->mode_blob); - +drm_property_unreference_blob (crtc->state->mode_blob); state =to_mtk_crtc_state (crtc->state);memset (state,0 ,sizeof (*state)); }else {
Jinpu Wang
Reviewed-byRe: [PATCH] SCSI-aic94xx: Delete unnecessary checks before the function call "kmem_cache_destroy"
In reply to SF Markus ElfringQuoted 38 lines · SF Markus Elfring
Quoted 24 lines
From: Markus Elfring <[email protected]>
Date: Tue, 17 Nov 2015 08:14:52 +0100The
kmem_cache_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/scsi/aic94xx/aic94xx_init.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/scsi/aic94xx/aic94xx_init.c +0
-1@@ -660,12 +660,9 @@ Err:static void asd_destroy_global_caches (void ) { -if (asd_dma_token_cache)drivers/scsi/aic94xx/aic94xx_init.c Err: · line 668
Quoted 10 lines
drivers/scsi/aic94xx/aic94xx_init.c +2
-4-kmem_cache_destroy (asd_dma_token_cache); +kmem_cache_destroy (asd_dma_token_cache); asd_dma_token_cache =NULL ; - -if (asd_ascb_cache) -kmem_cache_destroy (asd_ascb_cache); +kmem_cache_destroy (asd_ascb_cache); asd_ascb_cache =NULL ; }How do you think about to integrate this update suggestion into another source code repository?
Quoted 2 lines
Regards,
Markus
Looks good to me!
PS: resend to fix mal-format rejection, sorry!
Signature · 4 lines
Mit freundlichen Grüßen, Best Regards, Jack Wang
Re: [PATCH] zsmalloc: Delete an unnecessary check before the function call "iput"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Fri, 22 Jul 2016 19:54:20 +0200The
iput()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Thanks!
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: staging: ks7010: Rename jump labels
In reply to SF Markus ElfringHi Markus,
Quoted 5 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines
How do you think about information from the chapter "7: Centralized exiting of functions"?
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodingStyle?idGef4ad2684d380dd6d596140fb79395115c3950#n389I'm not impressed by this piece of documentation.
Quoted 8 lines
I would also appreciate further improvements there.
Quoted 3 lines
Back to the lack of space before labels, it's at best a personal preference. If you insist on standardizing, I'd call it a bug in the documentation, which should be fixed. One space before label is the way to go.
Would you like to contribute another patch for such a coding style issue?
I just sent a patch out, let's see what people think about it.
Quoted 8 lines
Quoted 2 lines
That being said... checkpatch does not complain about leading space before labels. Not even with --strict. So why are you mentioning it here?
How do you think about a similar software update?
staging: lustre: Fix a jump label position in
osc_get_info()
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?idÇ1d264543f759fea147734cb63de36397817534
https://lkml.org/lkml/2015/12/21/401
Intending labels with a tab is wrong, so fixing it is welcome. I'd turn the tab into a space instead, for reasons explained before, but no indentation at all is still better than a tab.
Signature · 6 lines
Jean Delvare SUSE L3 Support -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: staging: ks7010: Rename jump labels
In reply to SF Markus ElfringHi Markus,
Quoted 8 lines · SF Markus Elfring
Quoted 3 lines
Quoted 1 line
How do you generally think about jump label renaming?
Renaming from "out0:", "out1:" etc to something meaningful, yes.
I suggest to take another look at such identifiers.
Would you like to support the renaming of a label like "
error_out1" (in the function "ks7010_upload_firmware" for example)?
They should be renamed too. Anything using numbers instead of explicit labels should be updated. I included the reasons in the patch I just sent, hopefully the documentation is clearer now.
Quoted 4 lines
Will the software evolution be continued also with information from the topic "Source code review around jump label usage"?
https://lkml.org/lkml/2015/12/11/378
http://article.gmane.org/gmane.linux.kernel/2106190
Personally I see no value in such statistics. Either labels are wrong (either wrong indentation or wrong name) and should be fixed, or they are correct and you should not touch them. Whether the same label name is used somewhere else is irrelevant. Labels are local by nature, so uniqueness isn't a goal at all, only correctness.
Signature · 2 lines
Jean Delvare SUSE L3 Support
Re: [PATCH 1/3] IB/mthca: Delete an unnecessary check before the function call "pci_dev_put"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 10:05:12 +0200The
pci_dev_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Thanks,
Re: [PATCH 2/3] IB/mthca: Less function calls in mthca_reset() after error detection
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 11:28:30 +0200The
kfree()function was called in a few cases by themthca_reset()function during error handling even if the passed variables "bridge_header" and "hca_header" contained a null pointer.Adjust jump targets according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>
Thanks,
Re: staging: ks7010: Rename jump labels
In reply to Jean DelvareQuoted 4 lines
Quoted 2 lines
Would you like to support the renaming of a label like "
error_out1" (in the function "ks7010_upload_firmware" for example)?They should be renamed too. Anything using numbers instead of explicit
Interesting …
Quoted 1 line
Anything using numbers instead of explicit labels should be updated.
Would you dare to search for corresponding update candidates explicitly by special semantic patch scripts?
Quoted 2 lines
I included the reasons in the patch I just sent,
hopefully the documentation is clearer now.
I am curious on how feedback will evolve for your suggestion "CodingStyle: Clarify and complete chapter 7".
https://lkml.org/lkml/2016/7/25/207
How do you think about to show a shorter label like "free_bar" (instead of "err_free_bar") as an example?
Quoted 5 lines
Quoted 3 lines
"Source code review around jump label usage"?
https://lkml.org/lkml/2015/12/11/378
http://article.gmane.org/gmane.linux.kernel/2106190Personally I see no value in such statistics.
Do they indicate any code smells eventually?
Quoted 2 lines
Either labels are wrong (either wrong indentation or wrong name) and should be fixed, or they are correct and you should not touch them.
Do you find such changes worthwhile (without touching also any surrounding source code)?
Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] coresight: tmc: Delete an unnecessary check before the function call "kfree"
In reply to SF Markus ElfringQuoted 27 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 20:04:09 +0200The
kfree()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/hwtracing/coresight/coresight-tmc-etf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hwtracing/coresight/coresight-tmc-etf.c +1
-2@@ -168,7 +168,7 @@ out:spin_unlock_irqrestore (&drvdata->spinlock, flags);/* Free memory outside the spinlock if need be */ -if (!used && buf) +if (!used)kfree (buf);if (!ret) --
Quoted 2 lines
2.9.2
Applied - thanks.
Mathieu
Re: [PATCH] Input-rmi_bus: Delete an unnecessary check before the function call "of_node_put"
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 07:37:23 +0200The
of_node_put()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied, thank you.
Quoted 23 lines
--- drivers/input/rmi4/rmi_bus.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)drivers/input/rmi4/rmi_bus.c +1
-4@@ -232,10 +232,7 @@ err_put_device:void rmi_unregister_function (struct rmi_function *fn) {device_del (&fn->dev); - -if (fn->dev.of_node) -of_node_put (fn->dev.of_node); - +of_node_put (fn->dev.of_node);put_device (&fn->dev); }Signature · 1 line
2.9.2
Signature · 1 line
Dmitry
Re: [PATCH 3/3] staging: wilc1000: Reduce scope for a few variables in mac_ioctl()
In reply to SF Markus Elfringdrivers/staging/wilc1000/linux_wlan.c static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) · line 1121
Quoted 5 lines
drivers/staging/wilc1000/linux_wlan.c +3
-1-if (strncasecmp (buff,"RSSI" , length) =0 ) { +if (strncasecmp (buff,"RSSI" ,0 ) =0 ) { +s8 rssi; +
Um, please think a second about if it makes any sense at all to compare zero chars of two strings.
Lino
Re: [PATCH 3/3] staging: wilc1000: Reduce scope for a few variables in mac_ioctl()
Am 25.07.2016 21:17, schrieb Lino Sanfilippo:
Quoted 10 lines
drivers/staging/wilc1000/linux_wlan.c static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) · line 1121
Quoted 5 lines
drivers/staging/wilc1000/linux_wlan.c +3
-1-if (strncasecmp (buff,"RSSI" , length) =0 ) { +if (strncasecmp (buff,"RSSI" ,0 ) =0 ) { +s8 rssi; +Um, please think a second about if it makes any sense at all to compare zero chars of two strings.
Lino
also:
the switch has only one case and default.
re,
wh
PATCH 1/1 staging: rtl8188eu: Delete an unnecessary check before the function call "vfree"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Mon, 25 Jul 2016 22:20:24 +0200
The vfree() function performs also input parameter validation. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/rtl8188eu/core/rtw_xmit.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/rtl8188eu/core/rtw_xmit.c +1 -4
@@ -252,10 +252,7 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) pxmitbuf++; } -if (pxmitpriv->pallocated_xmit_extbuf) { -vfree (pxmitpriv->pallocated_xmit_extbuf); - } - +vfree (pxmitpriv->pallocated_xmit_extbuf);rtw_free_hwxmits (padapter);mutex_destroy (&pxmitpriv->ack_tx_mutex);
Signature · 1 line
2.9.2
Re: staging: ks7010: Rename jump labels
In reply to SF Markus ElfringHello Markus,
Quoted 5 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines
Would you like to support the renaming of a label like "
error_out1" (in the function "ks7010_upload_firmware" for example)?They should be renamed too. Anything using numbers instead of explicit
Quoted 7 lines
Interesting …
Quoted 1 line
Anything using numbers instead of explicit labels should be updated.
Would you dare to search for corresponding update candidates explicitly by special semantic patch scripts?
No. You started it all, and I do not have more time to devote to it. I do not find it all particularly interesting, to be honest. I have a lot of other things to work on, of much greater interest (to me.)
Quoted 9 lines
Quoted 2 lines
I included the reasons in the patch I just sent,
hopefully the documentation is clearer now.I am curious on how feedback will evolve for your suggestion "CodingStyle: Clarify and complete chapter 7".
https://lkml.org/lkml/2016/7/25/207How do you think about to show a shorter label like "
free_bar" (instead of "err_free_bar") as an example?
Up to whoever writes and maintains the code. As most things should be in the absence of a compelling reason to normalize.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
"Source code review around jump label usage"?
https://lkml.org/lkml/2015/12/11/378
http://article.gmane.org/gmane.linux.kernel/2106190Personally I see no value in such statistics.
Do they indicate any code smells eventually?
I have no idea what you mean, sorry.
Quoted 5 lines
Quoted 2 lines
Either labels are wrong (either wrong indentation or wrong name) and should be fixed, or they are correct and you should not touch them.
Do you find such changes worthwhile (without touching also any surrounding source code)?
You keep asking more and more from me. May I remind you this is your "project" in the first place, not mine? If you have no idea what should be done, or even whether anything should be done, then just move on to something else. I have already expressed all my views on this topic and am not willing to say anything more about it.
Thanks,
Signature · 7 lines
Jean Delvare SUSE L3 Support -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: staging: wilc1000: Reduce scope for a few variables in mac_ioctl()
In reply to Lino SanfilippoQuoted 7 lines
drivers/staging/wilc1000/linux_wlan.c static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) · line 1121
Quoted 4 lines
drivers/staging/wilc1000/linux_wlan.c +3
-1-if (strncasecmp (buff,"RSSI" , length) =0 ) { +if (strncasecmp (buff,"RSSI" ,0 ) =0 ) { +s8 rssi; +Um, please think a second about if it makes any sense at all to compare zero chars of two strings.
Under which circumstances should the variable "length" contain an other value than zero?
How can this open issue be fixed better?
Regards,
Markus
Re: staging: ks7010: Rename jump labels
In reply to Jean DelvareQuoted 1 line
I have a lot of other things to work on, of much greater interest (to me.)
This is fine.
Thanks for your feedback.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Personally I see no value in such statistics.
Do they indicate any code smells eventually?
I have no idea what you mean, sorry.
How do you think about to take another look at additional views around software development methodologies?
Examples:
https://en.wikipedia.org/wiki/Code_smell
https://en.wikipedia.org/wiki/Software_metric#Common_software_measurements
Do you occasionally care about a length distribution for identifiers (like goto labels) of up to 39 characters?
Quoted 1 line
You keep asking more and more from me.
I am looking also for further clarification based on your responses.
Quoted 1 line
May I remind you this is your "project" in the first place, not mine?
I invite also others to contribute to such a software evolution.
Quoted 1 line
If you have no idea what should be done,
I have got some ideas for changes. I am just unsure on how the corresponding acceptance will evolve.
Quoted 1 line
or even whether anything should be done, then just move on to something else.
This can also happen.
Quoted 1 line
I have already expressed all my views on this topic
I guess that related information will be reconsidered later.
Quoted 1 line
and am not willing to say anything more about it.
I would interpret the suggestion "CodingStyle: Clarify and complete chapter 7" in the way that your interest grew for a moment.
https://lkml.org/lkml/2016/7/25/207
https://www.mail-archive.com/[email protected]/msg1195846.html
I am curious if you are going to contribute to the proposed improvement a bit more.
Regards,
Markus
Re: [PATCH] cxl: Delete an unnecessary check before the function call "of_node_put"
In reply to Julia LawallQuoted 3 lines · Julia Lawall
I don't think that the call should be there at all. The loop only exits when
afu_npis NULL. Furthermore, the loop should not be written as a for loop, but rather withfor_each_child_of_node.
Will send a patch to fix both issues shortly.
Signature · 2 lines
Andrew Donnellan OzLabs, ADL Canberra [email protected] IBM Australia Limited
Aw: Re: staging: wilc1000: Reduce scope for a few variables in mac_ioctl()
In reply to SF Markus ElfringQuoted 14 lines
Gesendet: Dienstag, 26. Juli 2016 um 08:25 Uhr
Von: "SF Markus Elfring" <[email protected]>Quoted 7 lines
drivers/staging/wilc1000/linux_wlan.c static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) · line 1121
Quoted 4 lines
drivers/staging/wilc1000/linux_wlan.c +3
-1-if (strncasecmp (buff,"RSSI" , length) =0 ) { +if (strncasecmp (buff,"RSSI" ,0 ) =0 ) { +s8 rssi; +Um, please think a second about if it makes any sense at all to compare zero chars of two strings.
Quoted 2 lines
Under which circumstances should the variable "length" contain an other value than zero?
Which circumstances do "not any sense at all" imply?
Quoted 2 lines
How can this open issue be fixed better?
The code is not too complicated and I think it is very obvious which value/variable should be passed instead of 0. I suggest to fix this since it is indeed a bug, instead of doing "micro optimizations" - which is the last thing that code in the staging area needs (as IIRC you have already been told by others, including the staging maintainer).
Regards,
Lino
Re: [PATCH 2/3] staging: wilc1000: One function call less in mac_ioctl() after error detection
In reply to SF Markus ElfringHi Marcus,
Quoted 11 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 21:15:23 +0200The
kfree()function was called in two cases by themac_ioctl()function during error handling even if the passed variable did not contain a pointer for a valid data item.Improve this implementation detail by the introduction of another jump label.
Signed-off-by Markus Elfring <[email protected]>
This is pointless micro-optimisation: kfree(NULL) is perfectly valid and buff is either malloc'd memory or NULL when it's called.
Thanks,
Signature · 4 lines
Julian Calaby Email: [email protected] Profile: http://www.google.com/profiles/julian.calaby/
Alex Deucher
AppliedRe: [PATCH] GPU-DRM-Radeon: Delete an unnecessary check before drm_gem_object_unreference_unlocked()
In reply to SF Markus ElfringQuoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 12 Jul 2016 22:00:55 +0200The
drm_gem_object_unreference_unlocked()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Applied. thanks!
Alex
Quoted 26 lines
--- drivers/gpu/drm/radeon/radeon_display.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/gpu/drm/radeon/radeon_display.c +1
-4@@ -1324,9 +1324,7 @@ static void radeon_user_framebuffer_destroy(struct drm_framebuffer *fb) {struct radeon_framebuffer *radeon_fb =to_radeon_framebuffer (fb); -if (radeon_fb->obj) { -drm_gem_object_unreference_unlocked (radeon_fb->obj); - } +drm_gem_object_unreference_unlocked (radeon_fb->obj);drm_framebuffer_cleanup (fb);kfree (radeon_fb); } --2.9.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: staging: wilc1000: Reduce scope for a few variables in mac_ioctl()
In reply to Lino SanfilippoQuoted 1 line
Which circumstances do "not any sense at all" imply?
Should the expression 'strlen("RSSI")' be passed for the parameter 'length' instead?
Quoted 1 line
I suggest to fix this since it is indeed a bug,
We can agree that this function implementation was broken for a while there.
Quoted 2 lines
instead of doing "micro optimizations" - which is the last thing that code in the staging area needs (as IIRC you have already been told by others, including the staging maintainer).
The acceptance might grow a bit more for such software fine-tuning (like refactoring around variable usage).
Regards,
Markus
Re: [PATCH 0/8] drm/amdgpu: Fine-tuning for three function implementations
In reply to Christian KönigQuoted 15 lines · Christian König
Am 16.07.2016 um 16:33 schrieb SF Markus Elfring:
Quoted 6 lines
From: Markus Elfring <[email protected]>
Date: Sat, 16 Jul 2016 16:23:21 +0200Further update suggestions were taken into account after patches were applied from static source code analysis.
Small coding style nit pick on patch #7:
Review
Quoted 4 lines
(quoted diff) +2
-1- } + } else + temp_storage = NULL;
Quoted 6 lines
When an "if" has "{" and "}" the else should also use them even when it is only one line.
With that fixed the whole series is Reviewed-by: Christian König <[email protected]>, but as Walter Harms pointed out as well there are a couple of other things we could make more as well.
Applied the series except patch 2 was which already fixed by an earlier patch.
Thanks!
Alex
Quoted 25 lines
Regards,
Christian.Quoted 14 lines
Markus Elfring (8):
Delete an unnecessary check beforedrm_gem_object_unreference_unlocked()
Delete unnecessary checks before the function call "kfree" One function call less inamdgpu_cgs_acpi_eval_object()after error
detection
Delete a variable inamdgpu_cgs_acpi_eval_object()
Delete an unnecessary variable initialisation inamdgpu_cgs_acpi_eval_object()
Change assignment for a variable inamdgpu_cgs_acpi_eval_object()Change assignment for a buffer variable inphm_dispatch_table()Delete an unnecessary variable initialisation inphm_dispatch_table()Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 28 ++++++++++------------ drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 +--- .../gpu/drm/amd/powerplay/hwmgr/functiontables.c | 12 ++++------ 3 files changed, 19 insertions(+), 25 deletions(-)
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] PM-wakeup: Delete unnecessary checks before three function calls
In reply to SF Markus ElfringQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 17:04:00 +0200The following functions test whether their argument is NULL and then return immediately.
*dev_pm_arm_wake_irq
*dev_pm_disarm_wake_irq
*wakeup_source_unregister
Quoted 5 lines
Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
PATCH 1/1 cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put()
In reply to Andrew DonnellanRewrite the cxl_guest_init_afu() loop in cxl_of_probe() to use for_each_child_of_node() rather than a hand-coded for loop.
Remove the useless of_node_put(afu_np) call after the loop, where it's guaranteed that afu_np = NULL.
---
Checked the of_node_put() with Fred, he thinks it was probably just left over from an earlier private version of the code and we can just get rid of it.
--- drivers/misc/cxl/of.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/misc/cxl/of.c +3 -5
@@ -460,7 +460,7 @@ int cxl_of_probe(struct platform_device *pdev)struct device_node *afu_np =NULL ;struct cxl *adapter =NULL ;int ret; -int slice, slice_ok; +int slice =0 , slice_ok =0 ;pr_devel ("in %s\n" , __func__);
@@ -476,13 +476,13 @@ int cxl_of_probe(struct platform_device *pdev) }/* init afu */ - slice_ok =0 ; -for (afu_np =NULL , slice =0 ; (afu_np =of_get_next_child (np, afu_np)); slice++) { +for_each_child_of_node (np, afu_np) {if ((ret =cxl_guest_init_afu (adapter, slice, afu_np)))dev_err (&pdev->dev,"AFU %i failed to initialise: %i\n" , slice, ret);else slice_ok++; + slice++; }if (slice_ok =0 ) {
@@ -490,8 +490,6 @@ int cxl_of_probe(struct platform_device *pdev) adapter->slices =0 ; } -if (afu_np) -of_node_put (afu_np);return 0 ; }
Signature · 2 lines
Andrew Donnellan OzLabs, ADL Canberra [email protected] IBM Australia Limited
Re: [PATCH] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put()
Quoted 9 lines · Andrew Donnellan
Rewrite the
cxl_guest_init_afu()loop incxl_of_probe()to usefor_each_child_of_node()rather than a hand-coded for loop.Remove the useless
of_node_put(afu_np)call after the loop, where it's guaranteed thatafu_np= NULL.Reported-by SF Markus Elfring <[email protected]>Reported-by Julia Lawall <[email protected]>Signed-off-by Andrew Donnellan <[email protected]>
Thanks!
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put()
In reply to Andrew DonnellanAm 29.07.2016 05:55, schrieb Andrew Donnellan:
Quoted 36 lines
Rewrite the
cxl_guest_init_afu()loop incxl_of_probe()to usefor_each_child_of_node()rather than a hand-coded for loop.Remove the useless
of_node_put(afu_np)call after the loop, where it's guaranteed thatafu_np= NULL.Reported-by SF Markus Elfring <[email protected]>Reported-by Julia Lawall <[email protected]>Signed-off-by Andrew Donnellan <[email protected]>---
Checked the
of_node_put()with Fred, he thinks it was probably just left over from an earlier private version of the code and we can just get rid of it.--- drivers/misc/cxl/of.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)drivers/misc/cxl/of.c +1
-1@@ -460,7 +460,7 @@ int cxl_of_probe(struct platform_device *pdev)struct device_node *afu_np =NULL ;struct cxl *adapter =NULL ;int ret; -int slice, slice_ok; +int slice =0 , slice_ok =0 ;pr_devel ("in %s\n" , __func__);@@ -476,13 +476,13 @@ int cxl_of_probe(struct platform_device *pdev) }/* init afu */
drivers/misc/cxl/of.c int cxl_of_probe(struct platform_device *pdev) · line 486
Quoted 10 lines
drivers/misc/cxl/of.c +2
-2- slice_ok =0 ; -for (afu_np =NULL , slice =0 ; (afu_np =of_get_next_child (np, afu_np)); slice++) { +for_each_child_of_node (np, afu_np) {if ((ret =cxl_guest_init_afu (adapter, slice, afu_np)))dev_err (&pdev->dev,"AFU %i failed to initialise: %i\n" , slice, ret);else slice_ok++; + slice++; }
while you are here ..
you could move the assign out of the condition..
ret = cxl_guest_init_afu(adapter, slice, afu_np);
if (ret) ....
just my 2 cents,
re,
wh
Quoted 11 lines
drivers/misc/cxl/of.c +0
-2if (slice_ok =0 ) {@@ -490,8 +490,6 @@ int cxl_of_probe(struct platform_device *pdev) adapter->slices =0 ; } -if (afu_np) -of_node_put (afu_np);return 0 ; }
Re: [PATCH] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put()
Quoted 53 lines · walter harms
Am 29.07.2016 05:55, schrieb Andrew Donnellan:
Quoted 36 lines
Rewrite the
cxl_guest_init_afu()loop incxl_of_probe()to usefor_each_child_of_node()rather than a hand-coded for loop.Remove the useless
of_node_put(afu_np)call after the loop, where it's guaranteed thatafu_np== NULL.Reported-by SF Markus Elfring <[email protected]>Reported-by Julia Lawall <[email protected]>Signed-off-by Andrew Donnellan <[email protected]>---
Checked the
of_node_put()with Fred, he thinks it was probably just left over from an earlier private version of the code and we can just get rid of it.--- drivers/misc/cxl/of.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)drivers/misc/cxl/of.c +1
-1@@ -460,7 +460,7 @@ int cxl_of_probe(struct platform_device *pdev)struct device_node *afu_np =NULL ;struct cxl *adapter =NULL ;int ret; -int slice, slice_ok; +int slice =0 , slice_ok =0 ;pr_devel ("in %s\n" , __func__);@@ -476,13 +476,13 @@ int cxl_of_probe(struct platform_device *pdev) }/* init afu */ drivers/misc/cxl/of.c int cxl_of_probe(struct platform_device *pdev) · line 486
Quoted 10 lines
drivers/misc/cxl/of.c +2
-2- slice_ok =0 ; -for (afu_np =NULL , slice =0 ; (afu_np =of_get_next_child (np, afu_np)); slice++) { +for_each_child_of_node (np, afu_np) {if ((ret =cxl_guest_init_afu (adapter, slice, afu_np)))dev_err (&pdev->dev,"AFU %i failed to initialise: %i\n" , slice, ret);else slice_ok++; + slice++; }while you are here ..
you could move the assign out of the condition..
Quoted 2 lines
ret =
cxl_guest_init_afu(adapter, slice, afu_np);
if (ret) ....
Yes, please.
julia
Quoted 22 lines
just my 2 cents,
re,
whdrivers/misc/cxl/of.c int cxl_of_probe(struct platform_device *pdev) · line 495
Quoted 11 lines
drivers/misc/cxl/of.c +0
-2if (slice_ok ==0 ) {@@ -490,8 +490,6 @@ int cxl_of_probe(struct platform_device *pdev) adapter->slices =0 ; } -if (afu_np) -of_node_put (afu_np);return 0 ; }--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Michael Ellerman
reviewerRe: [PATCH] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put()
In reply to Andrew DonnellanQuoted 10 lines · Andrew Donnellan
Rewrite the
cxl_guest_init_afu()loop incxl_of_probe()to usefor_each_child_of_node()rather than a hand-coded for loop.Remove the useless
of_node_put(afu_np)call after the loop, where it's guaranteed thatafu_np= NULL.Reported-by SF Markus Elfring <[email protected]>Reported-by Julia Lawall <[email protected]>Signed-off-by Andrew Donnellan <[email protected]>
Quoted 5 lines
---
Checked the
of_node_put()with Fred, he thinks it was probably just left over from an earlier private version of the code and we can just get rid of it.
But who does keep a reference on the device_node? I can't see it anywhere. Which means in theory the device_node can be freed out from under you.
You have a reference for afu_np as part of for_each_child_of_node(), but it's dropped as soon as you go around the loop.
The typical pattern would be that cxl_guest_init_afu() takes an additional reference once it's done all its setup and can't fail.
That way at the end of the loop when the loop construct has dropped all references, the nodes you actually init'ed have their reference count incremented by 1.
cheers
Re: [PATCH] memory: omap-gpmc: Delete an unnecessary check before the function call "gpiochip_free_own_desc"
In reply to SF Markus ElfringHi Markus,
Quoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 18:54:02 +0200The
gpiochip_free_own_desc()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/memory/omap-gpmc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/memory/omap-gpmc.c +0
-0
drivers/memory/omap-gpmc.c err_child_fail: · line 2149
Quoted 10 lines
drivers/memory/omap-gpmc.c +1
-3@@ -2143,9 +2143,7 @@ err_child_fail: ret = -ENODEV ; err_cs: -if (waitpin_desc) -gpiochip_free_own_desc (waitpin_desc); - +gpiochip_free_own_desc (waitpin_desc); err:gpmc_cs_free (cs);
This looks good to me. I will queue this for v4.8. Thanks.
cheers,
-roger
Re: [PATCH] firmware-gsmi: Delete an unnecessary check before the function call "dma_pool_destroy"
In reply to SF Markus ElfringQuoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 10:16:56 +0200The
dma_pool_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.
Quoted 6 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/firmware/google/gsmi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Looks fine to me. If Mike doesn't pick this up I'll take it through the EFI tree.
Re: [PATCH] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put()
In reply to Michael EllermanQuoted 6 lines · Michael Ellerman
But who does keep a reference on the
device_node? I can't see it anywhere. Which means in theory thedevice_nodecan be freed out from under you.You have a reference for
afu_npas part offor_each_child_of_node(), but it's dropped as soon as you go around the loop.
Quoted 6 lines
The typical pattern would be that
cxl_guest_init_afu()takes an additional reference once it's done all its setup and can't fail.That way at the end of the loop when the loop construct has dropped all references, the nodes you actually init'ed have their reference count incremented by 1.
We don't keep a reference on the AFU device_node. Once we've read the config of the AFU, the AFU device_node is never accessed again. So I guess it's possible (though unexpected) that it's freed from under us, but it should not affect the driver.
The AFU is really dependent on the adapter itself, which is one level up in the device tree, and for which we create a device through of_platform_device_create(). The properties under the AFU device node are read directly from the PCI config space in the bare-metal case, where the cxl adapter is a PCI device.
Do we really have a problem here?
Fred
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] firmware-gsmi: Delete an unnecessary check before the function call "dma_pool_destroy"
In reply to Matt FlemingQuoted 10 lines · Matt Fleming
Quoted 8 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sun, 24 Jul 2016 10:16:56 +0200The
dma_pool_destroy()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Markus Elfring <[email protected]>--- drivers/firmware/google/gsmi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)Looks fine to me. If Mike doesn't pick this up I'll take it through the EFI tree.
Yes please do.
Doug Ledford
AppliedRe: [PATCH] IB/hfi1: Delete an unnecessary check before the function call "sc_return_credits"
In reply to a message not in the archiveQuoted 26 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 08:30:52 +0200The
sc_return_credits()function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>---
drivers/infiniband/hw/hfi1/file_ops.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/hfi1/file_ops.c +0
-0@@ -228,7 +228,7 @@ static long hfi1_file_ioctl(struct file *fp, unsigned int cmd, sizeof(struct hfi1_base_info)); break;case
HFI1_IOCTL_CREDIT_UPD:drivers/infiniband/hw/hfi1/file_ops.c +1
-1-if (uctxt && uctxt->sc) +if (uctxt)
Quoted 3 lines
sc_return_credits(uctxt->sc); break;
Thanks, applied.
Signature · 2 lines
Doug Ledford <[email protected]> GPG KeyID: 0E572FDD
Re: [PATCH 0/3] IB/mthca: Fine-tuning for mthca_reset()
In reply to SF Markus ElfringQuoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 23 Jul 2016 12:50:12 +0200Further update suggestions were taken into account after a patch was applied from static source code analysis.
Quoted 9 lines
Markus Elfring (3):
Delete an unnecessary check before the function call "pci_dev_put" Less function calls after error detection
Delete unnecessary variable initialisationsdrivers/infiniband/hw/mthca/mthca_reset.c | 48 +++++++++++++++----
------------1 file changed, 23 insertions(+), 25 deletions(-)
I applied 1 and 2, but skipped 3. My memory from long ago is that those variables didn't used to have initializers, but the compiler complained, so the initialization was added at some point. This is a dead driver, only around for the few systems out there using out dated hardware. I don't want to change this and then have to revert it because the old warnings came back, so I just dropped that patch.
Signature · 2 lines
Doug Ledford <[email protected]> GPG KeyID: 0E572FDD
Re: [PATCH] of: Delete an unnecessary check before the function call "of_node_put"
In reply to SF Markus ElfringQuoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 19 Jul 2016 22:42:22 +0200The
of_node_put()function tests whether its argument is NULL and then returns immediately.
Thus the test around the call is not needed.
Quoted 6 lines
This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- drivers/of/base.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Applied, thanks.
Rob
Re: staging: ks7010: Replace three printk() calls by pr_err()
In reply to Wolfram SangQuoted 3 lines
Quoted 1 line
Please and and use
pr_fmtCan't we use dev_* on the SDIO device?
How should a connection be constructed from the data structure "sdio_device_id" to the corresponding device information for such an use case?
Regards,
Markus
v2 cover staging: ks7010: Fine-tuning for a SDIO card driver
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Further update suggestions were taken into account after a patch was applied from static source code analysis.
Markus Elfring (10):
Delete unnecessary checks before the function call "kfree" Delete unnecessary assignments for buffer variables Return directly after a failed kmalloc()
Rename jump labels
Delete unnecessary uses of the variable "retval" Delete unnecessary braces
Add the macro "pr_fmt"
Replace three printk() calls by pr_err()
Delete a variable in write_to_device()
Delete three unnecessary variable initialisations
drivers/staging/ks7010/ks7010_sdio.c | 184 ++++++++++++++--------------------- 1 file changed, 73 insertions(+), 111 deletions(-)
Signature · 1 line
2.9.2
PATCH v2 1/10 staging: ks7010: Delete unnecessary checks before the function call "kfree"
From: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 17:15:15 +0200
The kfree() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
--- drivers/staging/ks7010/ks7010_sdio.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +4 -9
@@ -732,8 +732,7 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) goto error_out; } error_out: -if (data_buf) -kfree (data_buf); +kfree (data_buf);return rc; }
@@ -763,8 +762,7 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address, goto error_out; } error_out: -if (read_buf) -kfree (read_buf); +kfree (read_buf);return rc; }
@@ -879,8 +877,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,release_firmware (fw_entry); error_out0:sdio_release_host (card->func); -if (rom_buf) -kfree (rom_buf); +kfree (rom_buf);return rc; }
@@ -1199,9 +1196,7 @@ static void ks7010_sdio_remove(struct sdio_func *func)unregister_netdev (netdev);trx_device_exit (priv); -if (priv->ks_wlan_hw.read_buf) { -kfree (priv->ks_wlan_hw.read_buf); - } +kfree (priv->ks_wlan_hw.read_buf);free_netdev (priv->net_dev); card->priv =NULL ; }
Signature · 1 line
2.9.2
PATCH v2 2/10 staging: ks7010: Delete unnecessary assignments for buffer variables
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 17:26:01 +0200
A few variables were assigned a null pointer despite of the detail that they were immediately reassigned by the following statement. Thus remove such unnecessary assignments.
---
v2: Rebased on the source files from Linux next-20160809.
drivers/staging/ks7010/ks7010_sdio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +1 -4
@@ -711,7 +711,6 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)int rc =0 ;int retval;unsigned char *data_buf; - data_buf =NULL ; data_buf =kmalloc (sizeof (u32),GFP_KERNEL );if (!data_buf) {
@@ -743,7 +742,7 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,int rc =0 ;int retval;unsigned char *read_buf; - read_buf =NULL ; + read_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL );if (!read_buf) { rc =1 ;
@@ -776,8 +775,6 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,int length;const struct firmware *fw_entry =NULL ; - rom_buf =NULL ; -/* buffer allocate */ rom_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL );if (!rom_buf) {
Signature · 1 line
2.9.2
PATCH v2 3/10 staging: ks7010: Return directly after a failed kmalloc()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 17:34:12 +0200
Return directly after a memory allocation failed at the beginning.
---
v2: Rebased on the source files from Linux next-20160809.
drivers/staging/ks7010/ks7010_sdio.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +7 -12
@@ -713,10 +713,8 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)unsigned char *data_buf; data_buf =kmalloc (sizeof (u32),GFP_KERNEL ); -if (!data_buf) { - rc =1 ; - goto error_out; - } +if (!data_buf) +return 1 ;memcpy (data_buf, &index,sizeof (index)); retval =ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index));
@@ -744,10 +742,9 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,unsigned char *read_buf; read_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL ); -if (!read_buf) { - rc =1 ; - goto error_out; - } +if (!read_buf) +return 1 ; + retval =ks7010_sdio_read (priv, address, read_buf, size);if (retval) { rc =2 ;
@@ -777,10 +774,8 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,/* buffer allocate */ rom_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL ); -if (!rom_buf) { - rc =3 ; - goto error_out0; - } +if (!rom_buf) +return 3 ;sdio_claim_host (card->func);
Signature · 1 line
2.9.2
PATCH v2 4/10 staging: ks7010: Rename jump labels
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 17:57:50 +0200
Adjust jump targets according to the Linux coding style convention.
---
v2: Rebased on the source files from Linux next-20160809.
Touched four source code places less.
drivers/staging/ks7010/ks7010_sdio.c | 73 +++++++++++++++++------------------- 1 file changed, 34 insertions(+), 39 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +34 -39
@@ -523,18 +523,18 @@ static void ks7010_rw_function(struct work_struct *work)queue_delayed_work (priv->ks_wlan_hw.ks7010sdio_wq, &priv->ks_wlan_hw.rw_wq,1 ); } - goto err_out; + goto release_host; }/* sleep mode doze */ if (atomic_read (&priv->sleepstatus.doze_request) =1 ) {ks_wlan_hw_sleep_doze_request (priv); - goto err_out; + goto release_host; }/* sleep mode wakeup */ if (atomic_read (&priv->sleepstatus.wakeup_request) =1 ) {ks_wlan_hw_sleep_wakeup_request (priv); - goto err_out; + goto release_host; }/* read (WriteStatus/ReadDataSize FN1:00_0014) */
@@ -543,7 +543,7 @@ static void ks7010_rw_function(struct work_struct *work)if (retval) {DPRINTK (1 ," error : WSTATUS_RSIZE=%02X psstatus=%d\n" , rw_data,atomic_read (&priv->psstatus.status)); - goto err_out; + goto release_host; }DPRINTK (4 ,"WSTATUS_RSIZE=%02X\n" , rw_data);
@@ -555,8 +555,7 @@ static void ks7010_rw_function(struct work_struct *work)tx_device_task ((void *)priv); }_ks_wlan_hw_power_save (priv); - - err_out: + release_host:sdio_release_host (priv->ks_wlan_hw.sdio_card->func);return ;
@@ -720,15 +719,13 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index) retval =ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index));if (retval) { rc =2 ; - goto error_out; + goto free_buf; } retval =ks7010_sdio_write (priv,READ_INDEX , data_buf,sizeof (index)); -if (retval) { +if (retval) rc =3 ; - goto error_out; - } - error_out: + free_buf:kfree (data_buf);return rc; }
@@ -748,16 +745,15 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address, retval =ks7010_sdio_read (priv, address, read_buf, size);if (retval) { rc =2 ; - goto error_out; + goto free_buf; } retval =memcmp (data, read_buf, size);if (retval) {DPRINTK (0 ,"data compare error (%d) \n" , retval); rc =3 ; - goto error_out; } - error_out: + free_buf:kfree (read_buf);return rc; }
@@ -784,7 +780,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,if (rw_data =GCR_A_RUN ) {DPRINTK (0 ,"MAC firmware running ...\n" ); rc =0 ; - goto error_out0; + goto release_host; } retval =request_firmware (&fw_entry,ROM_FILE , &priv->ks_wlan_hw.sdio_card->func->dev);
@@ -814,14 +810,14 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv, KS7010_IRAM_ADDRESS + offset);if (retval) { rc =6 ; - goto error_out1; + goto release_fw; }/* Write data */ retval =ks7010_sdio_write (priv,DATA_WINDOW , rom_buf, size);if (retval) { rc =8 ; - goto error_out1; + goto release_fw; }/* compare */
@@ -829,7 +825,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,ks7010_sdio_data_compare (priv,DATA_WINDOW , rom_buf, size);if (retval) { rc =9 ; - goto error_out1; + goto release_fw; } n += size;
@@ -840,7 +836,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv, retval =ks7010_sdio_write (priv,GCR_A , &rw_data,sizeof (rw_data));if (retval) { rc =11 ; - goto error_out1; + goto release_fw; }DPRINTK (4 ," REMAP Request : GCR_A=%02X\n" , rw_data);
@@ -851,7 +847,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,ks7010_sdio_read (priv,GCR_A , &rw_data,sizeof (rw_data));if (retval) { rc =11 ; - goto error_out1; + goto release_fw; }if (rw_data =GCR_A_RUN )break ;
@@ -860,14 +856,13 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,if ((50 ) <= n) {DPRINTK (1 ,"firmware can't start\n" ); rc =12 ; - goto error_out1; + goto release_fw; } rc =0 ; - - error_out1: + release_fw:release_firmware (fw_entry); - error_out0: + release_host:sdio_release_host (card->func);kfree (rom_buf);return rc;
@@ -994,20 +989,20 @@ static int ks7010_sdio_probe(struct sdio_func *func, ret =sdio_enable_func (func);DPRINTK (5 ,"sdio_enable_func() %d\n" , ret);if (ret) - goto error_free_card; + goto free_card;/* interrupt disable */ sdio_writeb (func,0 ,INT_ENABLE , &ret);if (ret) - goto error_free_card; + goto free_card;sdio_writeb (func,0xff ,INT_PENDING , &ret);if (ret) - goto error_disable_func; + goto disable_func;/* setup interrupt handler */ ret =sdio_claim_irq (func, ks_sdio_interrupt);if (ret) - goto error_disable_func; + goto disable_func;sdio_release_host (func);
@@ -1020,11 +1015,11 @@ static int ks7010_sdio_probe(struct sdio_func *func, netdev =alloc_etherdev (sizeof (*priv));if (netdev =NULL ) {printk (KERN_ERR "ks7010 : Unable to alloc new net device\n" ); - goto error_release_irq; + goto release_irq; }if (dev_alloc_name (netdev,"wlan%d" ) <0 ) {printk (KERN_ERR "ks7010 : Couldn't get name!\n" ); - goto error_free_netdev; + goto free_dev; } priv =netdev_priv (netdev);
@@ -1038,7 +1033,7 @@ static int ks7010_sdio_probe(struct sdio_func *func, priv->ks_wlan_hw.read_buf =NULL ; priv->ks_wlan_hw.read_buf =kmalloc (RX_DATA_SIZE ,GFP_KERNEL );if (!priv->ks_wlan_hw.read_buf) { - goto error_free_netdev; + goto free_dev; } priv->dev_state =DEVICE_STATE_PREBOOT ; priv->net_dev = netdev;
@@ -1066,7 +1061,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,printk (KERN_ERR "ks7010: firmware load failed !! retern code = %d\n" , ret); - goto error_free_read_buf; + goto free_buf; }/* interrupt setting */
@@ -1094,7 +1089,7 @@ static int ks7010_sdio_probe(struct sdio_func *func, priv->ks_wlan_hw.ks7010sdio_wq =create_workqueue ("ks7010sdio_wq" );if (!priv->ks_wlan_hw.ks7010sdio_wq) {DPRINTK (1 ,"create_workqueue failed !!\n" ); - goto error_free_read_buf; + goto free_buf; }INIT_DELAYED_WORK (&priv->ks_wlan_hw.rw_wq, ks7010_rw_function);
@@ -1102,22 +1097,22 @@ static int ks7010_sdio_probe(struct sdio_func *func, ret =register_netdev (priv->net_dev);if (ret) - goto error_free_read_buf; + goto free_buf;return 0 ; - error_free_read_buf: + free_buf:kfree (priv->ks_wlan_hw.read_buf); priv->ks_wlan_hw.read_buf =NULL ; - error_free_netdev: + free_dev:free_netdev (priv->net_dev); card->priv =NULL ; - error_release_irq: + release_irq:sdio_claim_host (func);sdio_release_irq (func); - error_disable_func: + disable_func:sdio_disable_func (func); - error_free_card: + free_card:sdio_release_host (func);sdio_set_drvdata (func,NULL );kfree (card);
Signature · 1 line
2.9.2
PATCH v2 5/10 staging: ks7010: Delete unnecessary uses of the variable "retval"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 18:56:31 +0200
A few return values can also be directly used for condition checks. Thus remove a local variable for intermediate assignments.
---
v2: Rebased on the source files from Linux next-20160809.
Touched less source code places.
drivers/staging/ks7010/ks7010_sdio.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +3 -8
@@ -489,7 +489,6 @@ static void ks7010_rw_function(struct work_struct *work)struct hw_info_t *hw;struct ks_wlan_private *priv;unsigned char rw_data; -int retval; hw = container_of(work, struct hw_info_t, rw_wq.work); priv = container_of(hw, struct ks_wlan_private, ks_wlan_hw);
@@ -538,9 +537,7 @@ static void ks7010_rw_function(struct work_struct *work) }/* read (WriteStatus/ReadDataSize FN1:00_0014) */ - retval -ks7010_sdio_read (priv,WSTATUS_RSIZE , &rw_data,sizeof (rw_data)); -if (retval) { +if (ks7010_sdio_read (priv,WSTATUS_RSIZE , &rw_data,sizeof (rw_data))) {DPRINTK (1 ," error : WSTATUS_RSIZE=%02X psstatus=%d\n" , rw_data,atomic_read (&priv->psstatus.status)); goto release_host;
@@ -708,7 +705,6 @@ static void trx_device_exit(struct ks_wlan_private *priv)static int ks7010_sdio_update_index (struct ks_wlan_private *priv,u32 index) {int rc =0 ; -int retval;unsigned char *data_buf; data_buf =kmalloc (sizeof (u32),GFP_KERNEL );
@@ -716,14 +712,12 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)return 1 ;memcpy (data_buf, &index,sizeof (index)); - retval =ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index)); -if (retval) { +if (ks7010_sdio_write (priv,WRITE_INDEX , data_buf,sizeof (index))) { rc =2 ; goto free_buf; } - retval =ks7010_sdio_write (priv,READ_INDEX , data_buf,sizeof (index)); -if (retval) +if (ks7010_sdio_write (priv,READ_INDEX , data_buf,sizeof (index))) rc =3 ; free_buf:kfree (data_buf);
Signature · 1 line
2.9.2
PATCH v2 6/10 staging: ks7010: Delete unnecessary braces
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 19:57:01 +0200
Do not use curly brackets at some source code places where a single statement should be sufficient.
---
v2: Rebased on the source files from Linux next-20160809.
Touched less source code places.
drivers/staging/ks7010/ks7010_sdio.c | 46 +++++++++++++----------------------- 1 file changed, 16 insertions(+), 30 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +16 -30
@@ -383,10 +383,9 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, result =enqueue_txdev (priv, p, size, complete_handler, arg1, arg2);spin_unlock (&priv->tx_dev.tx_dev_lock); -if (cnt_txqbody (priv) >0 ) { +if (cnt_txqbody (priv) >0 )queue_delayed_work (priv->ks_wlan_hw.ks7010sdio_wq, &priv->ks_wlan_hw.rw_wq,0 ); - }return result; }
@@ -402,9 +401,8 @@ static void rx_event_task(unsigned long dev)hostif_receive (priv, rp->data, rp->size);inc_rxqhead (priv); -if (cnt_rxqbody (priv) >0 ) { +if (cnt_rxqbody (priv) >0 )tasklet_schedule (&priv->ks_wlan_hw.rx_bh_task); - } }return ;
@@ -432,9 +430,8 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size) retval ks7010_sdio_read(priv, DATA_WINDOW, &rx_buffer->data[0],hif_align_size (size )); -if (retval) { +if (retval) goto error_out; - }/* length check */ if (size >2046 || size =0 ) {
@@ -449,9 +446,8 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size) retval ks7010_sdio_write(priv, READ_STATUS, &read_status, sizeof(read_status)); -if (retval) { +if (retval)DPRINTK (1 ," error : READ_STATUS=%02X\n" , read_status); - } goto error_out; }
@@ -470,12 +466,11 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size) }DPRINTK (4 ,"READ_STATUS=%02X\n" , read_status); -if (atomic_read (&priv->psstatus.confirm_wait)) { +if (atomic_read (&priv->psstatus.confirm_wait))if (IS_HIF_CONF (event)) {DPRINTK (4 ,"IS_HIF_CONF true !!\n" );atomic_dec (&priv->psstatus.confirm_wait); } - }/* rx_event_task((void *)priv); */ tasklet_schedule (&priv->ks_wlan_hw.rx_bh_task);
@@ -544,13 +539,11 @@ static void ks7010_rw_function(struct work_struct *work) }DPRINTK (4 ,"WSTATUS_RSIZE=%02X\n" , rw_data); -if (rw_data &RSIZE_MASK ) {/* Read schedule */ +if (rw_data &RSIZE_MASK )/* Read schedule */ ks_wlan_hw_rx ((void *)priv, (uint16_t ) (((rw_data &RSIZE_MASK ) <<4 ))); - } -if ((rw_data &WSTATUS_MASK )) { +if (rw_data &WSTATUS_MASK )tx_device_task ((void *)priv); - }_ks_wlan_hw_power_save (priv); release_host:sdio_release_host (priv->ks_wlan_hw.sdio_card->func);
@@ -618,10 +611,9 @@ static void ks_sdio_interrupt(struct sdio_func *func) }DPRINTK (4 ,"WSTATUS_RSIZE=%02X\n" , rw_data); rsize = rw_data &RSIZE_MASK ; -if (rsize) {/* Read schedule */ +if (rsize)/* Read schedule */ ks_wlan_hw_rx ((void *)priv, (uint16_t ) (((rsize) <<4 ))); - }if (rw_data &WSTATUS_MASK ) {#if 0 if (status & INT_WRITE_STATUS
@@ -632,11 +624,10 @@ static void ks_sdio_interrupt(struct sdio_func *func)ks7010_sdio_write (priv,DATA_WINDOW , &rw_data,sizeof (rw_data)); -if (retval) { +if (retval)DPRINTK (1 ,"write DATA_WINDOW Failed!!(%d)\n" , retval); - } status &= ~INT_WRITE_STATUS; }else {#endif
@@ -877,13 +868,11 @@ static void ks7010_card_init(struct ks_wlan_private *priv)DPRINTK (5 ,"hostif_sme_enqueu()\n" );if (!wait_for_completion_interruptible_timeout - (&priv->confirm_wait,5 *HZ )) { + (&priv->confirm_wait,5 *HZ ))DPRINTK (1 ,"wait time out!! SME_START\n" ); - } -if (priv->mac_address_valid && priv->version_size) { +if (priv->mac_address_valid && priv->version_size) priv->dev_state =DEVICE_STATE_PREINIT ; - }hostif_sme_enqueue (priv,SME_GET_EEPROM_CKSUM );
@@ -905,9 +894,8 @@ static void ks7010_card_init(struct ks_wlan_private *priv)hostif_sme_enqueue (priv,SME_START_REQUEST );if (!wait_for_completion_interruptible_timeout - (&priv->confirm_wait,5 *HZ )) { + (&priv->confirm_wait,5 *HZ ))DPRINTK (1 ,"wait time out!! wireless parameter set\n" ); - }if (priv->dev_state >=DEVICE_STATE_PREINIT ) {DPRINTK (1 ,"DEVICE READY!!\n" );
@@ -1026,9 +1014,9 @@ static int ks7010_sdio_probe(struct sdio_func *func,init_completion (&priv->ks_wlan_hw.ks7010_sdio_wait); priv->ks_wlan_hw.read_buf =NULL ; priv->ks_wlan_hw.read_buf =kmalloc (RX_DATA_SIZE ,GFP_KERNEL ); -if (!priv->ks_wlan_hw.read_buf) { +if (!priv->ks_wlan_hw.read_buf) goto free_dev; - } + priv->dev_state =DEVICE_STATE_PREBOOT ; priv->net_dev = netdev; priv->firmware_version[0 ] ='\0' ;
@@ -1064,9 +1052,8 @@ static int ks7010_sdio_probe(struct sdio_func *func,sdio_claim_host (func); ret =ks7010_sdio_write (priv,INT_PENDING , &rw_data,sizeof (rw_data));sdio_release_host (func); -if (ret) { +if (ret)DPRINTK (1 ," error : INT_PENDING=%02X\n" , rw_data); - }DPRINTK (4 ," clear Interrupt : INT_PENDING=%02X\n" , rw_data);/* enable ks7010sdio interrupt (INT_GCR_B|INT_READ_STATUS|INT_WRITE_STATUS) */
@@ -1074,9 +1061,8 @@ static int ks7010_sdio_probe(struct sdio_func *func,sdio_claim_host (func); ret =ks7010_sdio_write (priv,INT_ENABLE , &rw_data,sizeof (rw_data));sdio_release_host (func); -if (ret) { +if (ret)DPRINTK (1 ," error : INT_ENABLE=%02X\n" , rw_data); - }DPRINTK (4 ," enable Interrupt : INT_ENABLE=%02X\n" , rw_data); priv->dev_state =DEVICE_STATE_BOOT ;
Signature · 1 line
2.9.2
PATCH v2 7/10 staging: ks7010: Add the macro "pr_fmt"
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 20:45:11 +0200
Add a definition for the macro "pr_fmt" so that its information can be used for consistent message output.
---
v2: Addition from source code review
drivers/staging/ks7010/ks7010_sdio.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/staging/ks7010/ks7010_sdio.c +2 -0
@@ -10,6 +10,8 @@* published by the Free Software Foundation. */ +#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/firmware.h> #include <linux/mmc/card.h> #include <linux/mmc/sdio_func.h>
Signature · 1 line
2.9.2
PATCH v2 8/10 staging: ks7010: Replace three printk() calls by pr_err()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 21:56:15 +0200
Prefer usage of the macro "pr_err" over the interface "printk". Fix a typo in an error message.
---
v2: Rebased on the source files from Linux next-20160809.
drivers/staging/ks7010/ks7010_sdio.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +3 -4
@@ -998,11 +998,11 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* private memory allocate */ netdev =alloc_etherdev (sizeof (*priv));if (netdev =NULL ) { -printk (KERN_ERR "ks7010 : Unable to alloc new net device\n" ); +pr_err (pr_fmt ("Unable to alloc new net device\n" )); goto release_irq; }if (dev_alloc_name (netdev,"wlan%d" ) <0 ) { -printk (KERN_ERR "ks7010 : Couldn't get name!\n" ); +pr_err (pr_fmt ("Couldn't get name!\n" )); goto free_dev; }
@@ -1042,8 +1042,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* Upload firmware */ ret =ks7010_upload_firmware (priv, card);/* firmware load */ if (ret) { -printk (KERN_ERR -"ks7010: firmware load failed !! retern code = %d\n" , +pr_err (pr_fmt ("firmware load failed! return code = %d\n" ), ret); goto free_buf; }
Signature · 1 line
2.9.2
PATCH v2 9/10 staging: ks7010: Delete a variable in write_to_device()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 22:10:20 +0200
The local variable "rc" was assigned a zero at one place. But it was not read within this function. Thus delete it.
---
v2: Rebased on the source files from Linux next-20160809.
drivers/staging/ks7010/ks7010_sdio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +1 -2
@@ -299,11 +299,10 @@ static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p,static int write_to_device (struct ks_wlan_private *priv,unsigned char *buffer,unsigned long size) { -int rc, retval; +int retval;unsigned char rw_data;struct hostif_hdr *hdr; hdr = (struct hostif_hdr *)buffer; - rc =0 ;DPRINTK (4 ,"size=%d\n" , hdr->size);if (hdr->event <HIF_DATA_REQ ||HIF_REQ_MAX < hdr->event) {
Signature · 1 line
2.9.2
PATCH v2 10/10 staging: ks7010: Delete three unnecessary variable initialisations
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 10 Aug 2016 22:33:52 +0200
Three variables will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.
---
v2: Rebased on the source files from Linux next-20160809.
It was omitted to reduce the scope for the variable "rc" in the function "tx_device_task".
drivers/staging/ks7010/ks7010_sdio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +3 -3
@@ -331,7 +331,7 @@ static void tx_device_task(void *dev) {struct ks_wlan_private *priv = (struct ks_wlan_private *)dev;struct tx_device_buffer *sp; -int rc =0 ; +int rc;DPRINTK (4 ,"\n" ); if (cnt_txqbody(priv) > 0
@@ -366,7 +366,7 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size,void (*complete_handler) (void *arg1,void *arg2), void *arg1, void *arg2) { - int result = 0; + int result;struct hostif_hdr *hdr; hdr = (struct hostif_hdr *)p;
@@ -747,7 +747,7 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,static int ks7010_upload_firmware (struct ks_wlan_private *priv,struct ks_sdio_card *card) { -unsigned int size, offset, n =0 ; +unsigned int size, offset, n;unsigned char *rom_buf;unsigned char rw_data =0 ;int retval, rc =0 ;
Signature · 1 line
2.9.2
Re: staging: ks7010: Replace three printk() calls by pr_err()
In reply to SF Markus ElfringQuoted 6 lines · SF Markus Elfring
Quoted 3 lines
Quoted 1 line
Please and and use
pr_fmtCan't we use dev_* on the SDIO device?
How should a connection be constructed from the data structure "
sdio_device_id" to the corresponding device information for such an use case?
What did you try so far?
Re: staging: ks7010: Replace three printk() calls by pr_err()
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Can't we use dev_* on the SDIO device?
How should a connection be constructed from the data structure "
sdio_device_id" to the corresponding device information for such an use case?What did you try so far?
Nothing what I would find noteworthy for increasing the usage of a function like "dev_err".
Are you on "a mission" to improve software around logging calls a bit more?
Regards,
Markus
Re: staging: ks7010: Replace three printk() calls by pr_err()
Quoted 5 lines
Nothing what I would find noteworthy for increasing the usage of a function like "
dev_err".Are you on "a mission" to improve software around logging calls a bit more?
I have two of those cards and I would like to know which one caused an error. dev_err helps with exactly that.
Re: [PATCH v2 08/10] staging: ks7010: Replace three printk() calls by pr_err()
In reply to SF Markus ElfringQuoted 1 line · SF Markus Elfring
Prefer usage of the macro "
pr_err" over the interface "printk".
Not correct
drivers/staging/ks7010/ks7010_sdio.c
Quoted 1 line
drivers/staging/ks7010/ks7010_sdio.c +0
-0
[]
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_probe(struct sdio_func *func, · line 1001
Quoted 6 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-1@@ -998,11 +998,11 @@ static int ks7010_sdio_probe(struct sdio_func *func, /* private memory allocate */ netdev = alloc_etherdev(sizeof(*priv)); if (netdev = NULL) { -printk (KERN_ERR "ks7010 : Unable to alloc new net device\n" ); +pr_err (pr_fmt ("Unable to alloc new net device\n" ));
All of these pr_fmt uses are redundant as pr_err already does pr_fmt alloc_etherdev already does a dump_stack so the OOM isn't useful.
Quoted 15 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-1goto release_irq; } if (dev_alloc_name(netdev, "wlan%d") < 0) { -printk (KERN_ERR "ks7010 : Couldn't get name!\n" ); +pr_err (pr_fmt ("Couldn't get name!\n" )); goto free_dev; }drivers/staging/ks7010/ks7010_sdio.c +0
-0@@ -1042,8 +1042,7 @@ static int ks7010_sdio_probe(struct sdio_func *func, /* Upload firmware */ret =
ks7010_upload_firmware(priv, card); /* firmware load */
if (ret) {drivers/staging/ks7010/ks7010_sdio.c +1
-2- printk(KERN_ERR - "ks7010: firmware load failed !! retern code = %d\n", + pr_err(pr_fmt("firmware load failed! return code = %d\n"),
Quoted 3 lines
ret);
gotofree_buf;
}
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: staging: ks7010: Replace three printk() calls by pr_err()
Quoted 2 lines
Quoted 1 line
Prefer usage of the macro "
pr_err" over the interface "printk".Not correct
A checkpatch warning like "PREFER_PR_LEVEL" can point additional possibilities out for this use case.
Would you like to introduce any of the higher level logging functions instead?
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c
Quoted 1 line
drivers/staging/ks7010/ks7010_sdio.c +0
-0[]
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_probe(struct sdio_func *func, · line 1001
Quoted 6 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-1@@ -998,11 +998,11 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* private memory allocate */ netdev =alloc_etherdev (sizeof (*priv));if (netdev =NULL ) { -printk (KERN_ERR "ks7010 : Unable to alloc new net device\n" ); +pr_err (pr_fmt ("Unable to alloc new net device\n" ));All of these
pr_fmtuses are redundant aspr_erralready doespr_fmt
Thanks for your reminder.
Would you accept that another update will be appended to the discussed patch series?
Quoted 1 line
alloc_etherdevalready does adump_stackso the OOM isn't useful.
Does this information indicate that this printk() (or pr_err()) call should be deleted?
Regards,
Markus
Re: staging: ks7010: Replace three printk() calls by pr_err()
Quoted 5 lines · SF Markus Elfring
Quoted 2 lines
Quoted 1 line
Prefer usage of the macro "
pr_err" over the interface "printk".Not correct
A checkpatch warning like "
PREFER_PR_LEVEL" can point additional possibilities out for this use case.
Would you like to introduce any of the higher level logging functions instead?
I think pr_<level> is OK if reworking the code
to support dev_<level> is not easy.
Quoted 10 lines
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c
Quoted 1 line
drivers/staging/ks7010/ks7010_sdio.c +0
-0[]
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_probe(struct sdio_func *func, · line 1001
Quoted 7 lines
drivers/staging/ks7010/ks7010_sdio.c +1
-1@@ -998,11 +998,11 @@ static int ks7010_sdio_probe(struct sdio_func *func, /* private memory allocate */ netdev = alloc_etherdev(sizeof(*priv)); if (netdev = NULL) { -printk (KERN_ERR "ks7010 : Unable to alloc new net device\n" ); +pr_err (pr_fmt ("Unable to alloc new net device\n" ));All of these
pr_fmtuses are redundant aspr_erralready doespr_fmt
Quoted 3 lines
Thanks for your reminder.
Would you accept that another update will be appended to the discussed patch series?
No. Patches should not knowingly introduce defects that are corrected in follow-on patches.
Quoted 3 lines
Quoted 1 line
alloc_etherdevalready does adump_stackso the OOM isn't useful.Does this information indicate that this
printk()(orpr_err()) call should be deleted?
Markus, I don't know if it's your lack of English comprehension or not, but it's fairly obvious from my reply that this line should be deleted, either in this patch or a follow-on.
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 00/10] staging: ks7010: Fine-tuning for a SDIO card driver
In reply to SF Markus ElfringQuoted 3 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Further update suggestions were taken into account
Which ones? Please describe them to ease review.
Quoted 1 line
after a patch was applied from static source code analysis.
I added some Acked- and Reviewed-by tags last time. Did the patches change or why didn't you add them?
Re: staging: ks7010: Replace three printk() calls by pr_err()
In reply to Joe PerchesQuoted 2 lines
I think pr_<level> is OK if reworking the code to support dev_<level> is not easy.
Thanks for this explanation. - It sounds more constructive than the previous short feedback "Not correct".
Quoted 4 lines
Quoted 1 line
Would you accept that another update will be appended to the discussed patch series?
No. Patches should not knowingly introduce defects that are corrected in follow-on patches.
This view is fine in principle.
I am just curious on the preferred sequence to fix the affected implementation details.
1. I imagine that my questionable update suggestion "[PATCH v2 08/10] staging: ks7010:
Replace three printk() calls by pr_err()" can be skipped and the remaining logging calls will be improved somehow a bit later.
Or:
2. Do you want a resend of this whole patch series?
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
alloc_etherdevalready does adump_stackso the OOM isn't useful.Does this information indicate that this
printk()(orpr_err()) call should be deleted?Markus, I don't know if it's your lack of English comprehension or not, but it's fairly obvious from my reply that this line should be deleted,
I was unsure if this view fits to a consensus also by other developers.
It might be that I can occasionally become picky to check if other contributors insist on the usage of a specific error message.
Quoted 1 line
either in this patch or a follow-on.
I would prefer another addition (or source code clean-up) later. Could it happen that so many error messages are update candidates (for deletion) so that no places remain where a pr_err() call would make sense in this software module?
Regards,
Markus
Re: staging: ks7010: Replace three printk() calls by pr_err()
Quoted 5 lines · SF Markus Elfring
Quoted 3 lines
I think
pr_is OK if reworking the code
to supportdev_is not easy.Thanks for this explanation. - It sounds more constructive than the previous short feedback "Not correct".
<frustration>
How do you need your food prepared?
Do others need to cut it for you to bite sized pieces? </frustration>
You might have noticed I also wrote in the same reply:
"All of these pr_fmt uses are redundant as pr_err already does pr_fmt"
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
Would you accept that another update will be appended to the discussed patch series?
No. Patches should not knowingly introduce defects that are corrected in follow-on patches.
This view is fine in principle.
It is not just principle.
It is a fundamental for kernel patch submission.
Quoted 9 lines
I am just curious on the preferred sequence to fix the affected implementation details.
1. I imagine that my questionable update suggestion "[PATCH v2 08/10] staging: ks7010:
Replace threeprintk()calls bypr_err()" can be skipped and the remaining logging calls will be improved somehow a bit later.Or:
2. Do you want a resend of this whole patch series?
I am not an upstream path.
Greg KH generally serves that function here.
My suggestion would be to resend the entire patchset as V(n+1).
Quoted 2 lines
It might be that I can occasionally become picky to check if other contributors insist on the usage of a specific error message.
You can be prone to understatement.
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: staging: ks7010: Replace three printk() calls by pr_err()
Quoted 3 lines
You might have noticed I also wrote in the same reply:
"All of these
pr_fmtuses are redundant aspr_erralready doespr_fmt"
I admit that I made another software development mistake there. - It might not matter much when a final fix could be to get rid of the three affected logging calls for example.
Quoted 2 lines
It is not just principle.
It is a fundamental for kernel patch submission.
I hope that this view supports still the reordering for update steps after some discussion.
Quoted 3 lines
I am not an upstream path.
Greg KH generally serves that function here.
My suggestion would be to resend the entire patchset as V(n+1).
I am curious if it would make sense to reduce the mail traffic a bit by finding out which software changes can be accepted already.
Regards,
Markus
Re: [PATCH v2 00/10] staging: ks7010: Fine-tuning for a SDIO card driver
In reply to Wolfram SangQuoted 1 line
I added some Acked- and Reviewed-by tags last time.
I noticed this of course.
Quoted 1 line
Did the patches change
Yes. - The amount of source code which I touched in this software module is different for the second series.
Quoted 1 line
or why didn't you add them?
I imagined that your acknowledgements to the previous approach might not fit to the current software development situation any more.
Regards,
Markus
Re: staging: ks7010: Replace three printk() calls by pr_err()
In reply to a message not in the archiveQuoted 1 line
Really now, this is basic fixes and cleanups,
I agree to this view to some degree.
Quoted 1 line
you have been asked many times in the past to move on beyond these,
It is more useful when more severe bugs or bigger software improvements can be found. Which source code clean-ups are picked better up by other contributors?
Quoted 2 lines
as you often times seem to end up wasting lots of people's times as they attempt to help you.
It can take a bit more time occasionally to achieve the desired consensus.
Quoted 1 line
Personally, I'm long past wishing to help you out here, sorry.
Other contributors will eventually continue the clarification of remaining open issues in the source file "ks7010_sdio.c".
Quoted 3 lines
I'll take "correct" patches, but that's it. No discussion of them, no arguing over theoreticals, and no telling you what I might, or might not, want to see done in the future, sorry.
I became aware about software development possibilities which can also matter here.
Yesterday Julia Lawall informed me about a presentation on the topic "Refactor strings – make everyone happy" by Wolfram Sang on 2016-07-14.
Is such a software evolution also interesting and acceptable for you?
Quoted 2 lines
And really, your patch quality stinks, I strongly suggest getting a lot more experience with C first before doing more kernel work please.
Can you accept any specific update steps while other software changes will evolve after a bit of discussion as usual?
Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Michael Ellerman
AppliedRe: cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put()
In reply to Andrew DonnellanQuoted 10 lines · Andrew Donnellan
Rewrite the
cxl_guest_init_afu()loop incxl_of_probe()to usefor_each_child_of_node()rather than a hand-coded for loop.Remove the useless
of_node_put(afu_np)call after the loop, where it's guaranteed thatafu_np= NULL.Reported-by SF Markus Elfring <[email protected]>Reported-by Julia Lawall <[email protected]>Signed-off-by Andrew Donnellan <[email protected]>Reviewed-by Frederic Barrat <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/735840b44bcc998e2574faf63d1aaa
cheers
Re: [B.A.T.M.A.N.] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
In reply to SF Markus ElfringQuoted 9 lines · On Freitag, 11. März 2016 13:40:56 CEST SF Markus Elfring wrote:
From: Markus Elfring <[email protected]>
Date: Fri, 11 Mar 2016 13:10:20 +0100The variables "
tt_local_entry" and "tt_global_entry" were eventually checked again despite of a corresponding null pointer test before.* Avoid this double check by reordering a function call sequence and the better selection of jump targets.
Quoted 7 lines
* Omit the initialisation for these variables at the beginning then.
Signed-off-by Markus Elfring <[email protected]>Reviewed-by Sven Eckelmann <[email protected]>--- net/batman-adv/translation-table.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
Applied in 58d8ef2dd0c9f7274f0473a1b1d1ffdacdd914f6 [1].
Kind regards,
Sven
[1] https://git.open-mesh.org/batman-adv.git/commit/58d8ef2dd0c9f7274f0473a1b1d1ffdacdd914f6
Re: [PATCH 11/13] ALSA: Deletion of checks before the function call "iounmap"
In reply to SF Markus ElfringSomeone was just mentioning in another thread that removing the check from iounmap() is not portable to other arches and then I remembered that Markus removed a bunch of these.
We should consider reverting this, perhaps?
regards,
dan carpenter
Quoted 476 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 3 Jan 2015 22:55:54 +0100The
iounmap()function performs also input parameter validation. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>--- sound/aoa/soundbus/i2sbus/core.c | 13 ++++++------- sound/arm/aaci.c | 4 ++-- sound/drivers/ml403-ac97cr.c | 3 +-- sound/isa/msnd/msnd_pinnacle.c | 3 +-- sound/parisc/harmony.c | 4 +--- sound/pci/ad1889.c | 5 +---- sound/pci/asihpi/hpioctl.c | 6 ++---- sound/pci/atiixp.c | 3 +-- sound/pci/atiixp_modem.c | 3 +-- sound/pci/aw2/aw2-alsa.c | 4 +--- sound/pci/bt87x.c | 3 +-- sound/pci/cs4281.c | 6 ++---- sound/pci/cs46xx/cs46xx_lib.c | 4 ++-- sound/pci/ctxfi/cthw20k1.c | 5 +---- sound/pci/ctxfi/cthw20k2.c | 5 +---- sound/pci/echoaudio/echoaudio.c | 6 +----- sound/pci/hda/hda_intel.c | 3 +-- sound/pci/lola/lola.c | 6 ++---- sound/pci/mixart/mixart.c | 7 +++---- sound/pci/nm256/nm256.c | 6 ++---- sound/pci/rme9652/hdsp.c | 4 +--- sound/pci/rme9652/hdspm.c | 4 +--- sound/pci/rme9652/rme9652.c | 3 +-- sound/pci/sis7019.c | 5 +---- sound/pci/ymfpci/ymfpci_main.c | 3 +-- sound/ppc/pmac.c | 15 +++++---------- 26 files changed, 43 insertions(+), 90 deletions(-)sound/aoa/soundbus/i2sbus/core.c +6
-7@@ -74,10 +74,9 @@ static void i2sbus_release_dev(struct device *dev)int i; i2sdev = container_of(dev, struct i2sbus_dev, sound.ofdev.dev); - -if (i2sdev->intfregs)iounmap (i2sdev->intfregs); -if (i2sdev->out.dbdma)iounmap (i2sdev->out.dbdma); -if (i2sdev->in.dbdma)iounmap (i2sdev->in.dbdma); +iounmap (i2sdev->intfregs); +iounmap (i2sdev->out.dbdma); +iounmap (i2sdev->in.dbdma);for (i = aoa_resource_i2smmio; i <= aoa_resource_rxdbdma; i++)release_and_free_resource (i2sdev->allocated_resource[i]);free_dbdma_descriptor_ring (i2sdev, &i2sdev->out.dbdma_ring);@@ -318,9 +317,9 @@ static int i2sbus_add_dev(struct macio_dev *macio,free_irq (dev->interrupts[i], dev);free_dbdma_descriptor_ring (dev, &dev->out.dbdma_ring);free_dbdma_descriptor_ring (dev, &dev->in.dbdma_ring); -if (dev->intfregs)iounmap (dev->intfregs); -if (dev->out.dbdma)iounmap (dev->out.dbdma); -if (dev->in.dbdma)iounmap (dev->in.dbdma); +iounmap (dev->intfregs); +iounmap (dev->out.dbdma); +iounmap (dev->in.dbdma);for (i=0 ;i<3 ;i++)release_and_free_resource (dev->allocated_resource[i]);mutex_destroy (&dev->lock);sound/arm/aaci.c +2
-2@@ -889,8 +889,8 @@ static int aaci_probe_ac97(struct aaci *aaci)static void aaci_free_card (struct snd_card *card) {struct aaci *aaci = card->private_data; -if (aaci->base) -iounmap (aaci->base); + +iounmap (aaci->base); }static struct aaci *aaci_init_card (struct amba_device *dev)sound/drivers/ml403-ac97cr.c +1
-2@@ -1094,8 +1094,7 @@ static int snd_ml403_ac97cr_free(struct snd_ml403_ac97cr *ml403_ac97cr)if (ml403_ac97cr->capture_irq >=0 )free_irq (ml403_ac97cr->capture_irq, ml403_ac97cr);/* give back "port" */ -if (ml403_ac97cr->port !=NULL ) -iounmap (ml403_ac97cr->port); +iounmap (ml403_ac97cr->port);kfree (ml403_ac97cr);PDEBUG (INIT_INFO ,"free(): (done)\n" );return 0 ;sound/isa/msnd/msnd_pinnacle.c +1
-2@@ -627,8 +627,7 @@ static int snd_msnd_attach(struct snd_card *card)return 0 ; err_release_region: -if (chip->mappedbase) -iounmap (chip->mappedbase); +iounmap (chip->mappedbase);release_mem_region (chip->base,BUFFSIZE );release_region (chip->io,DSP_NUMIO );free_irq (chip->irq, chip);sound/parisc/harmony.c +1
-3@@ -893,9 +893,7 @@ snd_harmony_free(struct snd_harmony *h)if (h->irq >=0 )free_irq (h->irq, h); -if (h->iobase) -iounmap (h->iobase); - +iounmap (h->iobase);kfree (h);return 0 ; }sound/pci/ad1889.c +1
-4@@ -853,12 +853,9 @@ snd_ad1889_free(struct snd_ad1889 *chip)free_irq (chip->irq, chip); skip_hw: -if (chip->iobase) -iounmap (chip->iobase); - +iounmap (chip->iobase);pci_release_regions (chip->pci);pci_disable_device (chip->pci); -kfree (chip);return 0 ; }sound/pci/asihpi/hpioctl.c +2
-4@@ -541,10 +541,8 @@ void asihpi_adapter_remove(struct pci_dev *pci_dev)hpi_send_recv_ex (&hm, &hr,HOWNER_KERNEL );/* unmap PCI memory space, mapped during device init. */ -for (idx =0 ; idx <HPI_MAX_ADAPTER_MEM_SPACES ; idx++) { -if (pci.ap_mem_base[idx]) -iounmap (pci.ap_mem_base[idx]); - } +for (idx =0 ; idx <HPI_MAX_ADAPTER_MEM_SPACES ; ++idx) +iounmap (pci.ap_mem_base[idx]);if (pa->irq)free_irq (pa->irq, pa);sound/pci/atiixp.c +1
-2@@ -1585,8 +1585,7 @@ static int snd_atiixp_free(struct atiixp *chip) __hw_end:if (chip->irq >=0 )free_irq (chip->irq, chip); -if (chip->remap_addr) -iounmap (chip->remap_addr); +iounmap (chip->remap_addr);pci_release_regions (chip->pci);pci_disable_device (chip->pci);kfree (chip);sound/pci/atiixp_modem.c +1
-2@@ -1211,8 +1211,7 @@ static int snd_atiixp_free(struct atiixp_modem *chip) __hw_end:if (chip->irq >=0 )free_irq (chip->irq, chip); -if (chip->remap_addr) -iounmap (chip->remap_addr); +iounmap (chip->remap_addr);pci_release_regions (chip->pci);pci_disable_device (chip->pci);kfree (chip);sound/pci/aw2/aw2-alsa.c +1
-3@@ -229,9 +229,7 @@ static int snd_aw2_dev_free(struct snd_device *device)if (chip->irq >=0 )free_irq (chip->irq, (void *)chip);/* release the i/o ports & memory */ -if (chip->iobase_virt) -iounmap (chip->iobase_virt); - +iounmap (chip->iobase_virt);pci_release_regions (chip->pci);/* disable the PCI entry */ pci_disable_device (chip->pci);sound/pci/bt87x.c +1
-2@@ -690,8 +690,7 @@ static int snd_bt87x_free(struct snd_bt87x *chip)snd_bt87x_stop (chip);if (chip->irq >=0 )free_irq (chip->irq, chip); -if (chip->mmio) -iounmap (chip->mmio); +iounmap (chip->mmio);pci_release_regions (chip->pci);pci_disable_device (chip->pci);kfree (chip);sound/pci/cs4281.c +2
-4@@ -1316,10 +1316,8 @@ static int snd_cs4281_free(struct cs4281 *chip)if (chip->irq >=0 )free_irq (chip->irq, chip); -if (chip->ba0) -iounmap (chip->ba0); -if (chip->ba1) -iounmap (chip->ba1); +iounmap (chip->ba0); +iounmap (chip->ba1);pci_release_regions (chip->pci);pci_disable_device (chip->pci);sound/pci/cs46xx/cs46xx_lib.c +2
-2@@ -2949,8 +2949,8 @@ static int snd_cs46xx_free(struct snd_cs46xx *chip)for (idx =0 ; idx <5 ; idx++) {struct snd_cs46xx_region *region = &chip->region.idx[idx]; -if (region->remap_addr) -iounmap (region->remap_addr); + +iounmap (region->remap_addr);release_and_free_resource (region->resource); }sound/pci/ctxfi/cthw20k1.c +1
-4@@ -1985,10 +1985,7 @@ static int hw_card_shutdown(struct hw *hw)free_irq (hw->irq, hw); hw->irq =-1 ; - -if (hw->mem_base) -iounmap (hw->mem_base); - +iounmap (hw->mem_base); hw->mem_base =NULL ;if (hw->io_base)sound/pci/ctxfi/cthw20k2.c +1
-4@@ -2110,10 +2110,7 @@ static int hw_card_shutdown(struct hw *hw)free_irq (hw->irq, hw); hw->irq =-1 ; - -if (hw->mem_base) -iounmap (hw->mem_base); - +iounmap (hw->mem_base); hw->mem_base =NULL ;if (hw->io_base)sound/pci/echoaudio/echoaudio.c +1
-5@@ -1872,12 +1872,8 @@ static int snd_echo_free(struct echoaudio *chip)if (chip->comm_page)snd_dma_free_pages (&chip->commpage_dma_buf); -if (chip->dsp_registers) -iounmap (chip->dsp_registers); - +iounmap (chip->dsp_registers);release_and_free_resource (chip->iores); - -pci_disable_device (chip->pci);/* release chip data */ sound/pci/hda/hda_intel.c +1
-2@@ -1138,8 +1138,7 @@ static int azx_free(struct azx *chip)free_irq (chip->irq, (void *)chip);if (chip->msi)pci_disable_msi (chip->pci); -if (chip->remap_addr) -iounmap (chip->remap_addr); +iounmap (chip->remap_addr);azx_free_stream_pages (chip);if (chip->region_requested)sound/pci/lola/lola.c +2
-4@@ -551,10 +551,8 @@ static void lola_free(struct lola *chip)lola_free_mixer (chip);if (chip->irq >=0 )free_irq (chip->irq, (void *)chip); -if (chip->bar[0 ].remap_addr) -iounmap (chip->bar[0 ].remap_addr); -if (chip->bar[1 ].remap_addr) -iounmap (chip->bar[1 ].remap_addr); +iounmap (chip->bar[0 ].remap_addr); +iounmap (chip->bar[1 ].remap_addr);if (chip->rb.area)snd_dma_free_pages (&chip->rb);pci_release_regions (chip->pci);sound/pci/mixart/mixart.c +3
-4@@ -1114,10 +1114,9 @@ static int snd_mixart_free(struct mixart_mgr *mgr) }/* release the i/o ports */ -for (i =0 ; i <2 ; i++) { -if (mgr->mem[i].virt) -iounmap (mgr->mem[i].virt); - } +for (i =0 ; i <2 ; ++i) +iounmap (mgr->mem[i].virt); +pci_release_regions (mgr->pci);/* free flowarray */ sound/pci/nm256/nm256.c +2
-4@@ -1460,10 +1460,8 @@ static int snd_nm256_free(struct nm256 *chip)if (chip->irq >=0 )free_irq (chip->irq, chip); -if (chip->cport) -iounmap (chip->cport); -if (chip->buffer) -iounmap (chip->buffer); +iounmap (chip->cport); +iounmap (chip->buffer);release_and_free_resource (chip->res_cport);release_and_free_resource (chip->res_buffer);sound/pci/rme9652/hdsp.c +1
-3@@ -5309,9 +5309,7 @@ static int snd_hdsp_free(struct hdsp *hdsp)release_firmware (hdsp->firmware);vfree (hdsp->fw_uploaded); - -if (hdsp->iobase) -iounmap (hdsp->iobase); +iounmap (hdsp->iobase);if (hdsp->port)pci_release_regions (hdsp->pci);sound/pci/rme9652/hdspm.c +1
-3@@ -6965,9 +6965,7 @@ static int snd_hdspm_free(struct hdspm * hdspm)free_irq (hdspm->irq, (void *) hdspm);kfree (hdspm->mixer); - -if (hdspm->iobase) -iounmap (hdspm->iobase); +iounmap (hdspm->iobase);if (hdspm->port)pci_release_regions (hdspm->pci);sound/pci/rme9652/rme9652.c +1
-2@@ -1756,8 +1756,7 @@ static int snd_rme9652_free(struct snd_rme9652 *rme9652)if (rme9652->irq >=0 )free_irq (rme9652->irq, (void *)rme9652); -if (rme9652->iobase) -iounmap (rme9652->iobase); +iounmap (rme9652->iobase);if (rme9652->port)pci_release_regions (rme9652->pci);sound/pci/sis7019.c +1
-4@@ -1064,12 +1064,9 @@ static int sis_chip_free(struct sis7019 *sis)if (sis->irq >=0 )free_irq (sis->irq, sis); -if (sis->ioaddr) -iounmap (sis->ioaddr); - +iounmap (sis->ioaddr);pci_release_regions (sis->pci);pci_disable_device (sis->pci); -sis_free_suspend (sis);return 0 ; }sound/pci/ymfpci/ymfpci_main.c +1
-2@@ -2246,8 +2246,7 @@ static int snd_ymfpci_free(struct snd_ymfpci *chip)release_and_free_resource (chip->mpu_res);release_and_free_resource (chip->fm_res);snd_ymfpci_free_gameport (chip); -if (chip->reg_area_virt) -iounmap (chip->reg_area_virt); +iounmap (chip->reg_area_virt);if (chip->work_ptr.area)snd_dma_free_pages (&chip->work_ptr);sound/ppc/pmac.c +5
-10@@ -867,16 +867,11 @@ static int snd_pmac_free(struct snd_pmac *chip)snd_pmac_dbdma_free (chip, &chip->capture.cmd);snd_pmac_dbdma_free (chip, &chip->extra_dma);snd_pmac_dbdma_free (chip, &emergency_dbdma); -if (chip->macio_base) -iounmap (chip->macio_base); -if (chip->latch_base) -iounmap (chip->latch_base); -if (chip->awacs) -iounmap (chip->awacs); -if (chip->playback.dma) -iounmap (chip->playback.dma); -if (chip->capture.dma) -iounmap (chip->capture.dma); +iounmap (chip->macio_base); +iounmap (chip->latch_base); +iounmap (chip->awacs); +iounmap (chip->playback.dma); +iounmap (chip->capture.dma);if (chip->node) {int i;Signature · 6 lines
2.2.1 -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Johannes Berg
maintainerRe: [PATCH 11/13] ALSA: Deletion of checks before the function call "iounmap"
Quoted 5 lines · Dan Carpenter
Someone was just mentioning in another thread that removing the check from
iounmap()is not portable to other arches and then I remembered that Markus removed a bunch of these.We should consider reverting this, perhaps?
Can't we teach all architectures? Not that reverting it would be a problem.
johannes
Re: [PATCH 11/13] ALSA: Deletion of checks before the function call "iounmap"
Quoted 9 lines · Johannes Berg
Quoted 5 lines · Dan Carpenter
Someone was just mentioning in another thread that removing the check from
iounmap()is not portable to other arches and then I remembered that Markus removed a bunch of these.We should consider reverting this, perhaps?
Can't we teach all architectures? Not that reverting it would be a problem.
We probably should. I just didn't want to suggest it, in case it sounds like volunteering... I'm not going to be able to do it because I'm on the road for a bit.
regards,
dan carpenter
PATCH 1/1 staging: ks7010: Adjust dev_err() calls in ks7010_sdio_probe()
In reply to Wolfram SangFrom: Markus Elfring <[email protected]>
Date: Tue, 11 Apr 2017 14:54:35 +0200
The use of the logging function "dev_err" was introduced here on 2016-09-26.
I find the following implementation details worth for another look.
* Reduce expressions for the first input parameter "dev".
* Omit an extra module prefix in passed error messages because the device name will be displayed by the function "__dev_printk".
--- drivers/staging/ks7010/ks7010_sdio.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +5 -6
@@ -955,12 +955,11 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* private memory allocate */ netdev =alloc_etherdev (sizeof (*priv));if (!netdev) { -dev_err (&card->func->dev,"ks7010 : Unable to alloc new net device\n" ); +dev_err (&func->dev,"Unable to alloc new net device\n" ); goto err_release_irq; }if (dev_alloc_name (netdev,"wlan%d" ) <0 ) { -dev_err (&card->func->dev, -"ks7010 : Couldn't get name!\n" ); +dev_err (&func->dev,"Couldn't get name!\n" ); goto err_free_netdev; }
@@ -1000,9 +999,9 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* Upload firmware */ ret =ks7010_upload_firmware (priv, card);/* firmware load */ if (ret) { -dev_err (&card->func->dev, -"ks7010: firmware load failed !! return code = %d\n" , - ret); +dev_err (&func->dev, +"firmware load failed! return code = %d\n" , + ret); goto err_free_read_buf; }
Signature · 1 line
2.12.2
Re: [PATCH] staging: ks7010: Adjust dev_err() calls in ks7010_sdio_probe()
Quoted 39 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 11 Apr 2017 14:54:35 +0200The use of the logging function "
dev_err" was introduced here on 2016-09-26.I find the following implementation details worth for another look.
* Reduce expressions for the first input parameter "dev".* Omit an extra module prefix in passed error messages because the device name will be displayed by the function "
__dev_printk".Fixes 9887b5e51fafaf919601ccb8bdae1e0ad749032f ("staging: ks7010: Fix warnings on printk() usage")Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +2
-3@@ -955,12 +955,11 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* private memory allocate */ netdev =alloc_etherdev (sizeof (*priv));if (!netdev) { -dev_err (&card->func->dev,"ks7010 : Unable to alloc new net device\n" ); +dev_err (&func->dev,"Unable to alloc new net device\n" ); goto err_release_irq; }if (dev_alloc_name (netdev,"wlan%d" ) <0 ) { -dev_err (&card->func->dev, -"ks7010 : Couldn't get name!\n" ); +dev_err (&func->dev,"Couldn't get name!\n" ); goto err_free_netdev; }@@ -1000,9 +999,9 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* Upload firmware */
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_probe(struct sdio_func *func, · line 1006
Quoted 10 lines
drivers/staging/ks7010/ks7010_sdio.c +3
-3ret =ks7010_upload_firmware (priv, card);/* firmware load */ if (ret) { -dev_err (&card->func->dev, -"ks7010: firmware load failed !! return code = %d\n" , - ret); +dev_err (&func->dev, +"firmware load failed! return code = %d\n" , + ret); goto err_free_read_buf; }
This patch does not apply to Greg's staging-testing branch. Sorry Markus a patch was merged the same day you submitted this one that refactored this code.
The patch was good though, good spotting.
Good luck,
Tobin.
Re: staging: ks7010: Adjust dev_err() calls in ks7010_sdio_probe()
Quoted 1 line
This patch does not apply to Greg's staging-testing branch.
Could the proposed changes be applied with a bit of “fuzz” for the implementation of the function “ks7010_sdio_probe”?
Quoted 2 lines
Markus a patch was merged the same day you submitted this one that refactored this code.
Do you refer to your contributions from 2017-04-10 here which seem to touch only other functions?
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/log/?h=staging-testing&qt=author&q=Tobin+C.+Harding
Quoted 1 line
The patch was good though, good spotting.
Will there any more approaches be needed for a corresponding editing conflict resolution?
Which day would be better to dare a resend for my small update suggestion?
Regards,
Markus
Greg Kroah-Hartman
maintainerRe: [PATCH] staging: ks7010: Adjust dev_err() calls in ks7010_sdio_probe()
In reply to Tobin C. HardingQuoted 38 lines · Tobin C. Harding
Quoted 37 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 11 Apr 2017 14:54:35 +0200The use of the logging function "
dev_err" was introduced here on 2016-09-26.I find the following implementation details worth for another look.
* Reduce expressions for the first input parameter "dev".* Omit an extra module prefix in passed error messages because the device name will be displayed by the function "
__dev_printk".Fixes 9887b5e51fafaf919601ccb8bdae1e0ad749032f ("staging: ks7010: Fix warnings on printk() usage")Signed-off-by Markus Elfring <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)drivers/staging/ks7010/ks7010_sdio.c +2
-3@@ -955,12 +955,11 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* private memory allocate */ netdev =alloc_etherdev (sizeof (*priv));if (!netdev) { -dev_err (&card->func->dev,"ks7010 : Unable to alloc new net device\n" ); +dev_err (&func->dev,"Unable to alloc new net device\n" ); goto err_release_irq; }if (dev_alloc_name (netdev,"wlan%d" ) <0 ) { -dev_err (&card->func->dev, -"ks7010 : Couldn't get name!\n" ); +dev_err (&func->dev,"Couldn't get name!\n" ); goto err_free_netdev; }
Quoted 16 lines
drivers/staging/ks7010/ks7010_sdio.c static int ks7010_sdio_probe(struct sdio_func *func, · line 1006
Quoted 12 lines
drivers/staging/ks7010/ks7010_sdio.c +3
-3@@ -1000,9 +999,9 @@ static int ks7010_sdio_probe(struct sdio_func *func,/* Upload firmware */ ret =ks7010_upload_firmware (priv, card);/* firmware load */ if (ret) { -dev_err (&card->func->dev, -"ks7010: firmware load failed !! return code = %d\n" , - ret); +dev_err (&func->dev, +"firmware load failed! return code = %d\n" , + ret); goto err_free_read_buf; }This patch does not apply to Greg's staging-testing branch. Sorry Markus a patch was merged the same day you submitted this one that refactored this code.
Note, Markus is in almost all maintainers kill-file, so we don't even see their emails, and I'd recommend you not even worry about them either.
thanks,
greg k-h