Message ID | fd9f738e-8e78-4afb-96fd-907f72fb4e13@web.de |
---|---|
State | New |
Headers | show |
Series | Bluetooth: qca: Use common error handling code in two functions | expand |
On Sun, 5 May 2024, Markus Elfring wrote: > From: Markus Elfring <elfring@users.sourceforge.net> > Date: Sun, 5 May 2024 10:30:28 +0200 > > Add a jump target so that the setting of an error code can be better reused > at the end of these function implementations. > > This issue was transformed by using the Coccinelle software. This reduces readability, and backwards jumps are rarely desirable. julia > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> > --- > drivers/bluetooth/btqca.c | 35 +++++++++++++++++------------------ > 1 file changed, 17 insertions(+), 18 deletions(-) > > diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c > index cc61014ffbc9..1833aaa6d87b 100644 > --- a/drivers/bluetooth/btqca.c > +++ b/drivers/bluetooth/btqca.c > @@ -108,10 +108,8 @@ static int qca_read_fw_build_info(struct hci_dev *hdev) > return err; > } > > - if (skb->len < sizeof(*edl)) { > - err = -EILSEQ; > - goto out; > - } > + if (skb->len < sizeof(*edl)) > + goto e_ilseq; > > edl = (struct edl_event_hdr *)(skb->data); > > @@ -123,17 +121,13 @@ static int qca_read_fw_build_info(struct hci_dev *hdev) > goto out; > } > > - if (skb->len < sizeof(*edl) + 1) { > - err = -EILSEQ; > - goto out; > - } > + if (skb->len < sizeof(*edl) + 1) > + goto e_ilseq; > > build_lbl_len = edl->data[0]; > > - if (skb->len < sizeof(*edl) + 1 + build_lbl_len) { > - err = -EILSEQ; > - goto out; > - } > + if (skb->len < sizeof(*edl) + 1 + build_lbl_len) > + goto e_ilseq; > > build_label = kstrndup(&edl->data[1], build_lbl_len, GFP_KERNEL); > if (!build_label) > @@ -145,6 +139,10 @@ static int qca_read_fw_build_info(struct hci_dev *hdev) > out: > kfree_skb(skb); > return err; > + > +e_ilseq: > + err = -EILSEQ; > + goto out; > } > > static int qca_send_patch_config_cmd(struct hci_dev *hdev) > @@ -224,8 +222,7 @@ static int qca_read_fw_board_id(struct hci_dev *hdev, u16 *bid) > edl = skb_pull_data(skb, sizeof(*edl)); > if (!edl) { > bt_dev_err(hdev, "QCA read board ID with no header"); > - err = -EILSEQ; > - goto out; > + goto e_ilseq; > } > > if (edl->cresp != EDL_CMD_REQ_RES_EVT || > @@ -235,10 +232,8 @@ static int qca_read_fw_board_id(struct hci_dev *hdev, u16 *bid) > goto out; > } > > - if (skb->len < 3) { > - err = -EILSEQ; > - goto out; > - } > + if (skb->len < 3) > + goto e_ilseq; > > *bid = (edl->data[1] << 8) + edl->data[2]; > bt_dev_dbg(hdev, "%s: bid = %x", __func__, *bid); > @@ -246,6 +241,10 @@ static int qca_read_fw_board_id(struct hci_dev *hdev, u16 *bid) > out: > kfree_skb(skb); > return err; > + > +e_ilseq: > + err = -EILSEQ; > + goto out; > } > > int qca_send_pre_shutdown_cmd(struct hci_dev *hdev) > -- > 2.44.0 > > >
This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series: PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=850522 ---Test result--- Test Summary: CheckPatch PASS 0.60 seconds GitLint PASS 0.28 seconds SubjectPrefix PASS 0.10 seconds BuildKernel PASS 29.70 seconds CheckAllWarning PASS 32.31 seconds CheckSparse PASS 38.38 seconds CheckSmatch FAIL 34.98 seconds BuildKernel32 PASS 28.68 seconds TestRunnerSetup PASS 518.82 seconds TestRunner_l2cap-tester PASS 18.36 seconds TestRunner_iso-tester FAIL 35.11 seconds TestRunner_bnep-tester PASS 4.80 seconds TestRunner_mgmt-tester PASS 111.01 seconds TestRunner_rfcomm-tester PASS 7.26 seconds TestRunner_sco-tester PASS 15.13 seconds TestRunner_ioctl-tester PASS 7.67 seconds TestRunner_mesh-tester PASS 5.85 seconds TestRunner_smp-tester PASS 6.82 seconds TestRunner_userchan-tester PASS 4.96 seconds IncrementalBuild PASS 27.54 seconds Details ############################## Test: CheckSmatch - FAIL Desc: Run smatch tool with source Output: Segmentation fault (core dumped) make[4]: *** [scripts/Makefile.build:244: net/bluetooth/hci_core.o] Error 139 make[4]: *** Deleting file 'net/bluetooth/hci_core.o' make[3]: *** [scripts/Makefile.build:485: net/bluetooth] Error 2 make[2]: *** [scripts/Makefile.build:485: net] Error 2 make[2]: *** Waiting for unfinished jobs.... Segmentation fault (core dumped) make[4]: *** [scripts/Makefile.build:244: drivers/bluetooth/bcm203x.o] Error 139 make[4]: *** Deleting file 'drivers/bluetooth/bcm203x.o' make[4]: *** Waiting for unfinished jobs.... make[3]: *** [scripts/Makefile.build:485: drivers/bluetooth] Error 2 make[2]: *** [scripts/Makefile.build:485: drivers] Error 2 make[1]: *** [/github/workspace/src/src/Makefile:1919: .] Error 2 make: *** [Makefile:240: __sub-make] Error 2 ############################## Test: TestRunner_iso-tester - FAIL Desc: Run iso-tester with test-runner Output: Total: 122, Passed: 121 (99.2%), Failed: 1, Not Run: 0 Failed Test Cases ISO Connect Suspend - Success Failed 4.169 seconds --- Regards, Linux Bluetooth
>> Add a jump target so that the setting of an error code can be better reused >> at the end of these function implementations. … > This reduces readability, and backwards jumps are rarely desirable. Would you like to support any other design approaches better for the reduction of questionable source code duplication? Regards, Markus
On Sun, 5 May 2024, Markus Elfring wrote: > >> Add a jump target so that the setting of an error code can be better reused > >> at the end of these function implementations. > … > > This reduces readability, and backwards jumps are rarely desirable. > > Would you like to support any other design approaches better for > the reduction of questionable source code duplication? Maybe cleanup.h can be used to get rid of the kfree_skb. I have no idea. It would be nice to keep the patch in the message so that one could see what is being discussed from the message itself. julia
On Sun, May 05, 2024 at 02:33:32AM -0700, bluez.test.bot@gmail.com wrote: > This is automated email and please do not reply to this email! > > Dear submitter, > > Thank you for submitting the patches to the linux bluetooth mailing list. > This is a CI test results with your patch series: > PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=850522 > > ---Test result--- > > Test Summary: > CheckPatch PASS 0.60 seconds > GitLint PASS 0.28 seconds > SubjectPrefix PASS 0.10 seconds > BuildKernel PASS 29.70 seconds > CheckAllWarning PASS 32.31 seconds > CheckSparse PASS 38.38 seconds > CheckSmatch FAIL 34.98 seconds > BuildKernel32 PASS 28.68 seconds > TestRunnerSetup PASS 518.82 seconds > TestRunner_l2cap-tester PASS 18.36 seconds > TestRunner_iso-tester FAIL 35.11 seconds > TestRunner_bnep-tester PASS 4.80 seconds > TestRunner_mgmt-tester PASS 111.01 seconds > TestRunner_rfcomm-tester PASS 7.26 seconds > TestRunner_sco-tester PASS 15.13 seconds > TestRunner_ioctl-tester PASS 7.67 seconds > TestRunner_mesh-tester PASS 5.85 seconds > TestRunner_smp-tester PASS 6.82 seconds > TestRunner_userchan-tester PASS 4.96 seconds > IncrementalBuild PASS 27.54 seconds > > Details > ############################## > Test: CheckSmatch - FAIL > Desc: Run smatch tool with source > Output: > > Segmentation fault (core dumped) > make[4]: *** [scripts/Makefile.build:244: net/bluetooth/hci_core.o] Error 139 > make[4]: *** Deleting file 'net/bluetooth/hci_core.o' > make[3]: *** [scripts/Makefile.build:485: net/bluetooth] Error 2 > make[2]: *** [scripts/Makefile.build:485: net] Error 2 > make[2]: *** Waiting for unfinished jobs.... > Segmentation fault (core dumped) > make[4]: *** [scripts/Makefile.build:244: drivers/bluetooth/bcm203x.o] Error 139 > make[4]: *** Deleting file 'drivers/bluetooth/bcm203x.o' > make[4]: *** Waiting for unfinished jobs.... > make[3]: *** [scripts/Makefile.build:485: drivers/bluetooth] Error 2 > make[2]: *** [scripts/Makefile.build:485: drivers] Error 2 > make[1]: *** [/github/workspace/src/src/Makefile:1919: .] Error 2 > make: *** [Makefile:240: __sub-make] Error 2 :( This is annoying... Are you using the latest release? The released code is working for me. regards, dan carpenter
diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c index cc61014ffbc9..1833aaa6d87b 100644 --- a/drivers/bluetooth/btqca.c +++ b/drivers/bluetooth/btqca.c @@ -108,10 +108,8 @@ static int qca_read_fw_build_info(struct hci_dev *hdev) return err; } - if (skb->len < sizeof(*edl)) { - err = -EILSEQ; - goto out; - } + if (skb->len < sizeof(*edl)) + goto e_ilseq; edl = (struct edl_event_hdr *)(skb->data); @@ -123,17 +121,13 @@ static int qca_read_fw_build_info(struct hci_dev *hdev) goto out; } - if (skb->len < sizeof(*edl) + 1) { - err = -EILSEQ; - goto out; - } + if (skb->len < sizeof(*edl) + 1) + goto e_ilseq; build_lbl_len = edl->data[0]; - if (skb->len < sizeof(*edl) + 1 + build_lbl_len) { - err = -EILSEQ; - goto out; - } + if (skb->len < sizeof(*edl) + 1 + build_lbl_len) + goto e_ilseq; build_label = kstrndup(&edl->data[1], build_lbl_len, GFP_KERNEL); if (!build_label) @@ -145,6 +139,10 @@ static int qca_read_fw_build_info(struct hci_dev *hdev) out: kfree_skb(skb); return err; + +e_ilseq: + err = -EILSEQ; + goto out; } static int qca_send_patch_config_cmd(struct hci_dev *hdev) @@ -224,8 +222,7 @@ static int qca_read_fw_board_id(struct hci_dev *hdev, u16 *bid) edl = skb_pull_data(skb, sizeof(*edl)); if (!edl) { bt_dev_err(hdev, "QCA read board ID with no header"); - err = -EILSEQ; - goto out; + goto e_ilseq; } if (edl->cresp != EDL_CMD_REQ_RES_EVT || @@ -235,10 +232,8 @@ static int qca_read_fw_board_id(struct hci_dev *hdev, u16 *bid) goto out; } - if (skb->len < 3) { - err = -EILSEQ; - goto out; - } + if (skb->len < 3) + goto e_ilseq; *bid = (edl->data[1] << 8) + edl->data[2]; bt_dev_dbg(hdev, "%s: bid = %x", __func__, *bid); @@ -246,6 +241,10 @@ static int qca_read_fw_board_id(struct hci_dev *hdev, u16 *bid) out: kfree_skb(skb); return err; + +e_ilseq: + err = -EILSEQ; + goto out; } int qca_send_pre_shutdown_cmd(struct hci_dev *hdev)