* [PATCH v2] net: ll_temac: Use one return statement instead of two
@ 2015-05-11 14:05 ` Michal Simek
0 siblings, 0 replies; 14+ messages in thread
From: Michal Simek @ 2015-05-11 14:05 UTC (permalink / raw)
To: netdev
Cc: Sören Brinkmann, monstr, Fabian Frederick, linux-kernel,
David S. Miller, Manuel Schölling, Julia Lawall,
Markus Elfring, Subbaraya Sundeep Bhatta, linux-arm-kernel
Use one return statement instead of two to simplify the code.
Both are returning the same value.
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
Changes in v2:
- Use the same SoB as sender address - Reported-by: Julia Lawall
drivers/net/ethernet/xilinx/ll_temac_main.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index 062483f334a5..cfb6bdb37fdc 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -688,10 +688,8 @@ static int temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
cur_p = &lp->tx_bd_v[lp->tx_bd_tail];
if (temac_check_tx_bd_space(lp, num_frag)) {
- if (!netif_queue_stopped(ndev)) {
+ if (!netif_queue_stopped(ndev))
netif_stop_queue(ndev);
- return NETDEV_TX_BUSY;
- }
return NETDEV_TX_BUSY;
}
--
2.3.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2] net: ll_temac: Use one return statement instead of two
@ 2015-05-11 14:05 ` Michal Simek
0 siblings, 0 replies; 14+ messages in thread
From: Michal Simek @ 2015-05-11 14:05 UTC (permalink / raw)
To: linux-arm-kernel
Use one return statement instead of two to simplify the code.
Both are returning the same value.
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
Changes in v2:
- Use the same SoB as sender address - Reported-by: Julia Lawall
drivers/net/ethernet/xilinx/ll_temac_main.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index 062483f334a5..cfb6bdb37fdc 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -688,10 +688,8 @@ static int temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
cur_p = &lp->tx_bd_v[lp->tx_bd_tail];
if (temac_check_tx_bd_space(lp, num_frag)) {
- if (!netif_queue_stopped(ndev)) {
+ if (!netif_queue_stopped(ndev))
netif_stop_queue(ndev);
- return NETDEV_TX_BUSY;
- }
return NETDEV_TX_BUSY;
}
--
2.3.5
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2] net: ll_temac: Use one return statement instead of two
2015-05-11 14:05 ` Michal Simek
(?)
@ 2015-05-11 14:42 ` Joe Perches
2015-05-11 15:26 ` Michal Simek
-1 siblings, 1 reply; 14+ messages in thread
From: Joe Perches @ 2015-05-11 14:42 UTC (permalink / raw)
To: Michal Simek; +Cc: linux-kernel, Julia Lawall, Markus Elfring
On Mon, 2015-05-11 at 16:05 +0200, Michal Simek wrote:
> Use one return statement instead of two to simplify the code.
> Both are returning the same value.
trivia and FYI:
I think there are about 100 of these in kernel tree
and I'm not going to submit patches.
$ grep-2.5.4 -rP --include=*.[ch] -n "^([\t]+)\treturn[ \t]+([A-Za-z0-9\_\>\(\)\.\>\[\]\-]+);\n(\1}\n)?\1return[ \t]+\2;" * | \
grep -P "^[\w\/\.]+:\d+:"
arch/x86/kvm/emulate.c:2122: return rc;
arch/um/kernel/exitcode.c:75: return 0;
arch/um/drivers/mconsole_kern.c:784: return 0;
arch/powerpc/include/asm/floppy.h:84: return IRQ_HANDLED;
drivers/gpu/drm/via/via_video.c:90: return 0;
drivers/gpu/drm/via/via_verifier.c:514: return 2;
drivers/gpu/drm/omapdrm/omap_fb.c:375: return fb;
drivers/gpu/drm/radeon/evergreen_cs.c:312: return -EINVAL;
drivers/gpu/drm/radeon/ni.c:2161: return r;
drivers/isdn/capi/capidrv.c:1682: return -EINVAL;
drivers/isdn/hisax/saphir.c:237: return (0);
drivers/isdn/hisax/teles3.c:249: return (0);
drivers/isdn/hisax/hfc_pci.c:1628: return (0);
drivers/isdn/hisax/ix1_micro.c:206: return (0);
drivers/isdn/hisax/avm_a1p.c:211: return 0;
drivers/isdn/hisax/w6692.c:987: return (0);
drivers/isdn/hisax/asuscom.c:292: return (0);
drivers/isdn/hisax/avm_a1.c:175: return (0);
drivers/isdn/hisax/hfcscard.c:133: return (0);
drivers/isdn/hisax/teleint.c:257: return (0);
drivers/isdn/hisax/hfc_sx.c:1379: return (0);
drivers/isdn/hisax/teles0.c:261: return (0);
drivers/isdn/hisax/mic.c:185: return (0);
drivers/isdn/hisax/nj_u.c:126: return (0);
drivers/isdn/hisax/bkm_a4t.c:251: return (0);
drivers/isdn/hisax/avm_pci.c:716: return (0);
drivers/isdn/hisax/bkm_a8.c:253: return (0);
drivers/isdn/hisax/sportster.c:181: return (0);
drivers/isdn/hisax/niccy.c:220: return 0;
drivers/isdn/hisax/telespci.c:281: return (0);
drivers/isdn/hisax/isurf.c:170: return (0);
drivers/isdn/hisax/gazel.c:427: return (0);
drivers/isdn/hisax/nj_s.c:146: return (0);
drivers/isdn/i4l/isdn_v110.c:613: return 0;
drivers/isdn/hardware/avm/b1.c:634: return IRQ_HANDLED;
drivers/staging/lustre/lustre/osc/osc_request.c:2429: return rc;
drivers/staging/dgap/dgap.c:421: return 0;
drivers/staging/comedi/drivers/ni_mio_common.c:4997: return 0;
drivers/staging/comedi/drivers/usbduxsigma.c:1245: return -EINVAL;
drivers/staging/comedi/drivers/cb_pcidas64.c:1961: return -EINVAL;
drivers/staging/comedi/drivers/usbdux.c:1384: return -EINVAL;
drivers/hid/wacom_wac.c:1063: return 0;
drivers/crypto/qat/qat_dh895xcc/adf_isr.c:144: return ret;
drivers/crypto/qat/qat_dh895xcc/adf_dh895xcc_hw_data.c:135: return DEV_SKU_UNKNOWN;
drivers/parisc/led.c:168: return 0;
drivers/block/drbd/drbd_receiver.c:3457: return tfm;
drivers/iio/light/tcs3472.c:180: return -EINVAL;
drivers/misc/genwqe/card_base.c:1335: return 0;
drivers/mfd/tps80031.c:267: return ret;
drivers/mfd/tps80031.c:307: return ret;
drivers/mfd/palmas.c:374: return ret;
drivers/char/tpm/tpm_infineon.c:308: return -EIO;
drivers/scsi/wd7000.c:1558: return FAILED;
drivers/scsi/scsi_error.c:720: return FAILED;
drivers/scsi/scsi_error.c:1920: return FAILED;
drivers/scsi/be2iscsi/be_mgmt.c:1414: return rc;
drivers/scsi/initio.c:2480: return host->phase;
drivers/scsi/qla2xxx/qla_mr.c:692: return str;
drivers/scsi/bfa/bfa_fcbuild.c:208: return FC_PARSE_OK;
drivers/scsi/arcmsr/arcmsr_hba.c:3736: return rtnval;
drivers/scsi/BusLogic.c:3317: return SUCCESS;
drivers/net/ethernet/xilinx/ll_temac_main.c:693: return NETDEV_TX_BUSY;
drivers/net/ethernet/qlogic/qlge/qlge_main.c:3251: return err;
drivers/net/ethernet/qlogic/qlge/qlge_main.c:3295: return err;
drivers/net/ethernet/qlogic/qlge/qlge_main.c:3638: return status;
drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c:1492: return 0;
drivers/net/wan/x25_asy.c:350: return NETDEV_TX_OK;
drivers/net/wireless/rtlwifi/rtl8192cu/mac.c:227: return rst;
drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c:1176: return err;
drivers/net/plip/plip.c:739: return OK;
drivers/net/plip/plip.c:853: return OK;
drivers/net/caif/caif_serial.c:411: return result;
drivers/spi/spi.c:1057: return ret;
drivers/usb/gadget/function/f_loopback.c:560: return ret;
drivers/infiniband/ulp/isert/ib_isert.c:2143: return ret;
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c:1808: return status;
drivers/infiniband/hw/ocrdma/ocrdma_hw.c:151: return IB_QPS_ERR;
drivers/infiniband/hw/ocrdma/ocrdma_hw.c:170: return OCRDMA_QPS_ERR;
drivers/infiniband/hw/cxgb4/iw_cxgb4.h:618: return IB_QPS_ERR;
drivers/infiniband/hw/mlx5/qp.c:1547: return 0;
drivers/media/pci/smipcie/smipcie.c:261: return ret;
drivers/media/i2c/tw2804.c:196: return 0;
drivers/video/fbdev/68328fb.c:355: return 0;
drivers/video/fbdev/vfb.c:378: return 0;
fs/namespace.c:1935: return mp;
kernel/auditsc.c:425: return 0;
kernel/trace/trace_uprobe.c:1192: return 0;
net/sctp/outqueue.c:150: return 0;
net/caif/cfctrl.c:112: return false;
net/ipv4/netfilter/nf_nat_snmp_basic.c:1299: return ret;
net/tipc/server.c:612: return ret;
sound/pci/riptide/riptide.c:2003: return err;
sound/pci/rme9652/hdsp.c:2711: return 0;
sound/core/compress_offload.c:879: return ret;
sound/core/seq/oss/seq_oss_timer.c:274: return 0;
sound/oss/sb_midi.c:100: return 1;
sound/soc/codecs/max98925.c:120: return 0;
tools/perf/util/config.c:391: return 0;
tools/perf/util/alias.c:13: return 0;
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] net: ll_temac: Use one return statement instead of two
2015-05-11 14:42 ` Joe Perches
@ 2015-05-11 15:26 ` Michal Simek
2015-05-11 15:39 ` Joe Perches
2015-05-11 15:42 ` Julia Lawall
0 siblings, 2 replies; 14+ messages in thread
From: Michal Simek @ 2015-05-11 15:26 UTC (permalink / raw)
To: Joe Perches, Michal Simek; +Cc: linux-kernel, Julia Lawall, Markus Elfring
On 05/11/2015 04:42 PM, Joe Perches wrote:
> On Mon, 2015-05-11 at 16:05 +0200, Michal Simek wrote:
>> Use one return statement instead of two to simplify the code.
>> Both are returning the same value.
>
> trivia and FYI:
But still correct right?
>
> I think there are about 100 of these in kernel tree
> and I'm not going to submit patches.
>
> $ grep-2.5.4 -rP --include=*.[ch] -n "^([\t]+)\treturn[ \t]+([A-Za-z0-9\_\>\(\)\.\>\[\]\-]+);\n(\1}\n)?\1return[ \t]+\2;" * | \
> grep -P "^[\w\/\.]+:\d+:"
Are you suggesting that someone else should send patches for it?
I expect that this is something what Julia can check with coccinelle
and can be added to scripts folder.
Thanks,
Michal
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] net: ll_temac: Use one return statement instead of two
2015-05-11 15:26 ` Michal Simek
@ 2015-05-11 15:39 ` Joe Perches
2015-05-11 15:44 ` Michal Simek
2015-05-11 15:42 ` Julia Lawall
1 sibling, 1 reply; 14+ messages in thread
From: Joe Perches @ 2015-05-11 15:39 UTC (permalink / raw)
To: Michal Simek; +Cc: linux-kernel, Julia Lawall, Markus Elfring
On Mon, 2015-05-11 at 17:26 +0200, Michal Simek wrote:
> On 05/11/2015 04:42 PM, Joe Perches wrote:
> > On Mon, 2015-05-11 at 16:05 +0200, Michal Simek wrote:
> >> Use one return statement instead of two to simplify the code.
> >> Both are returning the same value.
> >
> > trivia and FYI:
>
> But still correct right?
Yes.
> > I think there are about 100 of these in kernel tree
> > and I'm not going to submit patches.
> >
> > $ grep-2.5.4 -rP --include=*.[ch] -n "^([\t]+)\treturn[ \t]+([A-Za-z0-9\_\>\(\)\.\>\[\]\-]+);\n(\1}\n)?\1return[ \t]+\2;" * | \
> > grep -P "^[\w\/\.]+:\d+:"
>
> Are you suggesting that someone else should send patches for it?
I get enough grief for doing style oriented patches,
so if someone else wants to, sure.
> I expect that this is something what Julia can check with coccinelle
> and can be added to scripts folder.
Maybe true.
A coccinelle script might be rather more complicated
than the simpler grep above, but perhaps the script
could be a bit more complete as it could likely look
at more code indentation styles.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] net: ll_temac: Use one return statement instead of two
2015-05-11 15:26 ` Michal Simek
2015-05-11 15:39 ` Joe Perches
@ 2015-05-11 15:42 ` Julia Lawall
1 sibling, 0 replies; 14+ messages in thread
From: Julia Lawall @ 2015-05-11 15:42 UTC (permalink / raw)
To: Michal Simek; +Cc: Joe Perches, linux-kernel, Julia Lawall, Markus Elfring
On Mon, 11 May 2015, Michal Simek wrote:
> On 05/11/2015 04:42 PM, Joe Perches wrote:
> > On Mon, 2015-05-11 at 16:05 +0200, Michal Simek wrote:
> >> Use one return statement instead of two to simplify the code.
> >> Both are returning the same value.
> >
> > trivia and FYI:
>
> But still correct right?
>
> >
> > I think there are about 100 of these in kernel tree
> > and I'm not going to submit patches.
> >
> > $ grep-2.5.4 -rP --include=*.[ch] -n "^([\t]+)\treturn[ \t]+([A-Za-z0-9\_\>\(\)\.\>\[\]\-]+);\n(\1}\n)?\1return[ \t]+\2;" * | \
> > grep -P "^[\w\/\.]+:\d+:"
>
> Are you suggesting that someone else should send patches for it?
> I expect that this is something what Julia can check with coccinelle
> and can be added to scripts folder.
I can do something based on the original patch. I have no idea what the
regular expression does :)
julia
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] net: ll_temac: Use one return statement instead of two
2015-05-11 15:39 ` Joe Perches
@ 2015-05-11 15:44 ` Michal Simek
2015-05-11 15:48 ` Julia Lawall
2015-05-11 16:10 ` Joe Perches
0 siblings, 2 replies; 14+ messages in thread
From: Michal Simek @ 2015-05-11 15:44 UTC (permalink / raw)
To: Joe Perches, Michal Simek, Julia Lawall; +Cc: linux-kernel, Markus Elfring
On 05/11/2015 05:39 PM, Joe Perches wrote:
> On Mon, 2015-05-11 at 17:26 +0200, Michal Simek wrote:
>> On 05/11/2015 04:42 PM, Joe Perches wrote:
>>> On Mon, 2015-05-11 at 16:05 +0200, Michal Simek wrote:
>>>> Use one return statement instead of two to simplify the code.
>>>> Both are returning the same value.
>>>
>>> trivia and FYI:
>>
>> But still correct right?
>
> Yes.
Does this mean that you have added me your ACK?
>>> I think there are about 100 of these in kernel tree
>>> and I'm not going to submit patches.
>>>
>>> $ grep-2.5.4 -rP --include=*.[ch] -n "^([\t]+)\treturn[ \t]+([A-Za-z0-9\_\>\(\)\.\>\[\]\-]+);\n(\1}\n)?\1return[ \t]+\2;" * | \
>>> grep -P "^[\w\/\.]+:\d+:"
>>
>> Are you suggesting that someone else should send patches for it?
>
> I get enough grief for doing style oriented patches,
> so if someone else wants to, sure.
yep - the only reason I have submitted this was that this is the diff in
the xilinx tree compare to mainline and I don't want to simple revert it
because it is correct.
>> I expect that this is something what Julia can check with coccinelle
>> and can be added to scripts folder.
>
> Maybe true.
>
> A coccinelle script might be rather more complicated
> than the simpler grep above, but perhaps the script
> could be a bit more complete as it could likely look
> at more code indentation styles.
Julia: Any comment?
Thanks,
Michal
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] net: ll_temac: Use one return statement instead of two
2015-05-11 15:44 ` Michal Simek
@ 2015-05-11 15:48 ` Julia Lawall
2015-05-11 16:00 ` Joe Perches
2015-05-11 16:10 ` Joe Perches
1 sibling, 1 reply; 14+ messages in thread
From: Julia Lawall @ 2015-05-11 15:48 UTC (permalink / raw)
To: Michal Simek; +Cc: Joe Perches, linux-kernel, Markus Elfring
> > A coccinelle script might be rather more complicated
> > than the simpler grep above, but perhaps the script
> > could be a bit more complete as it could likely look
> > at more code indentation styles.
>
> Julia: Any comment?
Here is what I had in mind:
if (...) {
... when != goto l;
return C;
}
return C;
C is a constant, to avoid that its value depends on the code in the ...
julia
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] net: ll_temac: Use one return statement instead of two
2015-05-11 15:48 ` Julia Lawall
@ 2015-05-11 16:00 ` Joe Perches
2015-05-12 5:23 ` Julia Lawall
0 siblings, 1 reply; 14+ messages in thread
From: Joe Perches @ 2015-05-11 16:00 UTC (permalink / raw)
To: Julia Lawall; +Cc: Michal Simek, linux-kernel, Markus Elfring
On Mon, 2015-05-11 at 17:48 +0200, Julia Lawall wrote:
> > > A coccinelle script might be rather more complicated
> > > than the simpler grep above, but perhaps the script
> > > could be a bit more complete as it could likely look
> > > at more code indentation styles.
> >
> > Julia: Any comment?
>
> Here is what I had in mind:
>
> if (...) {
> ... when != goto l;
> return C;
> }
> return C;
>
> C is a constant, to avoid that its value depends on the code in the ...
Sure but I think that would miss several instances like:
switch (<foo>) {
...
default:
return <bar>;
}
return <bar>;
or the similar
if (foo) {
if (qux)
return <bar>;
} else {
return <baz>;
}
return <baz>;
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] net: ll_temac: Use one return statement instead of two
2015-05-11 15:44 ` Michal Simek
2015-05-11 15:48 ` Julia Lawall
@ 2015-05-11 16:10 ` Joe Perches
2015-05-11 16:12 ` Michal Simek
1 sibling, 1 reply; 14+ messages in thread
From: Joe Perches @ 2015-05-11 16:10 UTC (permalink / raw)
To: Michal Simek; +Cc: Julia Lawall, linux-kernel, Markus Elfring
On Mon, 2015-05-11 at 17:44 +0200, Michal Simek wrote:
> On 05/11/2015 05:39 PM, Joe Perches wrote:
> > On Mon, 2015-05-11 at 17:26 +0200, Michal Simek wrote:
> >> On 05/11/2015 04:42 PM, Joe Perches wrote:
> >>> On Mon, 2015-05-11 at 16:05 +0200, Michal Simek wrote:
> >>>> Use one return statement instead of two to simplify the code.
> >>>> Both are returning the same value.
> >>>
> >>> trivia and FYI:
> >>
> >> But still correct right?
> >
> > Yes.
>
> Does this mean that you have added me your ACK?
No,
I don't generally ack patches as I think it's
not very useful.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] net: ll_temac: Use one return statement instead of two
2015-05-11 16:10 ` Joe Perches
@ 2015-05-11 16:12 ` Michal Simek
0 siblings, 0 replies; 14+ messages in thread
From: Michal Simek @ 2015-05-11 16:12 UTC (permalink / raw)
To: Joe Perches, Michal Simek; +Cc: Julia Lawall, linux-kernel, Markus Elfring
On 05/11/2015 06:10 PM, Joe Perches wrote:
> On Mon, 2015-05-11 at 17:44 +0200, Michal Simek wrote:
>> On 05/11/2015 05:39 PM, Joe Perches wrote:
>>> On Mon, 2015-05-11 at 17:26 +0200, Michal Simek wrote:
>>>> On 05/11/2015 04:42 PM, Joe Perches wrote:
>>>>> On Mon, 2015-05-11 at 16:05 +0200, Michal Simek wrote:
>>>>>> Use one return statement instead of two to simplify the code.
>>>>>> Both are returning the same value.
>>>>>
>>>>> trivia and FYI:
>>>>
>>>> But still correct right?
>>>
>>> Yes.
>>
>> Does this mean that you have added me your ACK?
>
> No,
>
> I don't generally ack patches as I think it's
> not very useful.
OK. Fair enough.
Thanks,
Michal
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] net: ll_temac: Use one return statement instead of two
2015-05-11 14:05 ` Michal Simek
@ 2015-05-11 18:16 ` David Miller
-1 siblings, 0 replies; 14+ messages in thread
From: David Miller @ 2015-05-11 18:16 UTC (permalink / raw)
To: michal.simek
Cc: netdev, soren.brinkmann, monstr, fabf, linux-kernel,
manuel.schoelling, julia.lawall, elfring,
subbaraya.sundeep.bhatta, linux-arm-kernel
From: Michal Simek <michal.simek@xilinx.com>
Date: Mon, 11 May 2015 16:05:02 +0200
> Use one return statement instead of two to simplify the code.
> Both are returning the same value.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2] net: ll_temac: Use one return statement instead of two
@ 2015-05-11 18:16 ` David Miller
0 siblings, 0 replies; 14+ messages in thread
From: David Miller @ 2015-05-11 18:16 UTC (permalink / raw)
To: linux-arm-kernel
From: Michal Simek <michal.simek@xilinx.com>
Date: Mon, 11 May 2015 16:05:02 +0200
> Use one return statement instead of two to simplify the code.
> Both are returning the same value.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] net: ll_temac: Use one return statement instead of two
2015-05-11 16:00 ` Joe Perches
@ 2015-05-12 5:23 ` Julia Lawall
0 siblings, 0 replies; 14+ messages in thread
From: Julia Lawall @ 2015-05-12 5:23 UTC (permalink / raw)
To: Joe Perches; +Cc: Michal Simek, linux-kernel, Markus Elfring
On Mon, 11 May 2015, Joe Perches wrote:
> On Mon, 2015-05-11 at 17:48 +0200, Julia Lawall wrote:
> > > > A coccinelle script might be rather more complicated
> > > > than the simpler grep above, but perhaps the script
> > > > could be a bit more complete as it could likely look
> > > > at more code indentation styles.
> > >
> > > Julia: Any comment?
> >
> > Here is what I had in mind:
> >
> > if (...) {
> > ... when != goto l;
> > return C;
> > }
> > return C;
> >
> > C is a constant, to avoid that its value depends on the code in the ...
>
> Sure but I think that would miss several instances like:
>
> switch (<foo>) {
> ...
> default:
> return <bar>;
> }
> return <bar>;
Switch Coccinelle is not very good at...
> or the similar
>
> if (foo) {
> if (qux)
> return <bar>;
> } else {
> return <baz>;
> }
>
> return <baz>;
It seems improbable, but I could look for that. Unfortunately, I don't
see a way to deal with arbitrarily nested ifs. Basically, the control
flow from one return doesn't go to the other. It goes from the return to
the outside of the function. I guess something could be done by renaming
all of the returns to function calls, but that tends to make a mess. It
could be done to see if such cases are worth considering though.
Another similar and popular construction is:
if (...) {
...
goto l;
}
l:
julia
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2015-05-12 5:23 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-11 14:05 [PATCH v2] net: ll_temac: Use one return statement instead of two Michal Simek
2015-05-11 14:05 ` Michal Simek
2015-05-11 14:42 ` Joe Perches
2015-05-11 15:26 ` Michal Simek
2015-05-11 15:39 ` Joe Perches
2015-05-11 15:44 ` Michal Simek
2015-05-11 15:48 ` Julia Lawall
2015-05-11 16:00 ` Joe Perches
2015-05-12 5:23 ` Julia Lawall
2015-05-11 16:10 ` Joe Perches
2015-05-11 16:12 ` Michal Simek
2015-05-11 15:42 ` Julia Lawall
2015-05-11 18:16 ` David Miller
2015-05-11 18:16 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.