Re: [staging:staging-testing 62/88] drivers/staging/emxx_udc/emxx_udc.c:839:9: warning: Variable 'result' is reassigned a value before the old one has been used.
On Wed, Sep 02, 2020 at 11:15:47AM +0800, kernel test robot wrote: > tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git > staging-testing > head: 4c6491a343e91a5a2a699b0b545f8ba1ec1e8c65 > commit: fbcfdfab4a2c4ec5e2195929528506fec39388f3 [62/88] staging: emxx_udc: > Allow for building on !ARM > compiler: riscv32-linux-gcc (GCC) 9.3.0 [snip] > >> drivers/staging/emxx_udc/emxx_udc.c:2095:48: warning: Uninitialized > >> variable: ep [uninitvar] > list_for_each_entry(ep, >gadget.ep_list, ep.ep_list) { > ^ This warning's bogus. The ep here refers to a member name, not the variable ep. I'll send a patch for the other warnings though. > > # > https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/commit/?id=fbcfdfab4a2c4ec5e2195929528506fec39388f3 > git remote add staging > https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git > git fetch --no-tags staging staging-testing > git checkout fbcfdfab4a2c4ec5e2195929528506fec39388f3 > vim +/result +839 drivers/staging/emxx_udc/emxx_udc.c > > 33aa8d45a4fea3 Magnus Damm 2014-06-06 785 > 33aa8d45a4fea3 Magnus Damm 2014-06-06 786 > /*-*/ > e2d34dfdffcfd1 Cristian Sicilia2018-11-17 787 static int > _nbu2ss_out_dma(struct nbu2ss_udc *udc, struct nbu2ss_req *req, > e2d34dfdffcfd1 Cristian Sicilia2018-11-17 788 u32 > num, u32 length) > 33aa8d45a4fea3 Magnus Damm 2014-06-06 789 { > 5a012f67cbcb20 Alexis Lothoré 2017-05-10 790dma_addr_t > p_buffer; > 33aa8d45a4fea3 Magnus Damm 2014-06-06 791u32 mpkt; > 33aa8d45a4fea3 Magnus Damm 2014-06-06 792u32 lmpkt; > 33aa8d45a4fea3 Magnus Damm 2014-06-06 793u32 dmacnt; > 33aa8d45a4fea3 Magnus Damm 2014-06-06 794u32 burst = > 1; > 33aa8d45a4fea3 Magnus Damm 2014-06-06 795u32 data; > 33aa8d45a4fea3 Magnus Damm 2014-06-06 796int result > = -EINVAL; > 64407f6e7d158e Carmeli Tamir 2018-11-07 797struct fc_regs __iomem > *preg = udc->p_regs; > 33aa8d45a4fea3 Magnus Damm 2014-06-06 798 > 33aa8d45a4fea3 Magnus Damm 2014-06-06 799if (req->dma_flag) > 33aa8d45a4fea3 Magnus Damm 2014-06-06 800return 1; > /* DMA is forwarded */ > 33aa8d45a4fea3 Magnus Damm 2014-06-06 801 > 8b77d94e69c33f Saiyam Doshi2019-09-08 802req->dma_flag = true; > 5a012f67cbcb20 Alexis Lothoré 2017-05-10 803p_buffer = req->req.dma; > 5a012f67cbcb20 Alexis Lothoré 2017-05-10 804p_buffer += > req->req.actual; > 33aa8d45a4fea3 Magnus Damm 2014-06-06 805 > 33aa8d45a4fea3 Magnus Damm 2014-06-06 806/* DMA Address */ > 5a012f67cbcb20 Alexis Lothoré 2017-05-10 807 > _nbu2ss_writel(>EP_DCR[num].EP_TADR, (u32)p_buffer); > 33aa8d45a4fea3 Magnus Damm 2014-06-06 808 > 33aa8d45a4fea3 Magnus Damm 2014-06-06 809/* Number of transfer > packets */ > 75d9c393763da3 Alexis Lothoré 2017-05-10 810mpkt = > _nbu2ss_readl(>EP_REGS[num].EP_PCKT_ADRS) & EPN_MPKT; > 599b87809594e2 Janani Ravichandran 2016-02-11 811dmacnt = length / mpkt; > 33aa8d45a4fea3 Magnus Damm 2014-06-06 812lmpkt = (length % mpkt) > & ~(u32)0x03; > 33aa8d45a4fea3 Magnus Damm 2014-06-06 813 > 2866914ce1f84f Cristina Moraru 2015-09-29 814if (dmacnt > > DMA_MAX_COUNT) { > 33aa8d45a4fea3 Magnus Damm 2014-06-06 815dmacnt = > DMA_MAX_COUNT; > 33aa8d45a4fea3 Magnus Damm 2014-06-06 816lmpkt = 0; > 2866914ce1f84f Cristina Moraru 2015-09-29 817} else if (lmpkt != 0) { > 2866914ce1f84f Cristina Moraru 2015-09-29 818if (dmacnt == 0) > 33aa8d45a4fea3 Magnus Damm 2014-06-06 819burst = > 0; /* Burst OFF */ > 33aa8d45a4fea3 Magnus Damm 2014-06-06 820dmacnt++; > 33aa8d45a4fea3 Magnus Damm 2014-06-06 821} > 33aa8d45a4fea3 Magnus Damm 2014-06-06 822 > 33aa8d45a4fea3 Magnus Damm 2014-06-06 823data = mpkt | (lmpkt << > 16); > 33aa8d45a4fea3 Magnus Damm 2014-06-06 824 > _nbu2ss_writel(>EP_DCR[num].EP_DCR2, data); > 33aa8d45a4fea3 Magnus Damm 2014-06-06 825 > 75d9c393763da3 Alexis Lothoré 2017-05-10 826data = ((dmacnt & 0xff) > << 16) | DCR1_EPN_DIR0 | DCR1_EPN_REQEN; > 33aa8d45a4fea3 Magnus Damm 2014-06-06 827 > _nbu2ss_writel(>EP_DCR[num].EP_DCR1, data); > 33aa8d45a4fea3 Magnus Damm 2014-06-06 828 > 2866914ce1f84f Cristina Moraru 2015-09-29 829if (burst == 0) { > 33aa8d45a4fea3 Magnus Damm 2014-06-06 830 > _nbu2ss_writel(>EP_REGS[num].EP_LEN_DCNT, 0); > 75d9c393763da3
[staging:staging-testing 62/88] drivers/staging/emxx_udc/emxx_udc.c:839:9: warning: Variable 'result' is reassigned a value before the old one has been used.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git staging-testing head: 4c6491a343e91a5a2a699b0b545f8ba1ec1e8c65 commit: fbcfdfab4a2c4ec5e2195929528506fec39388f3 [62/88] staging: emxx_udc: Allow for building on !ARM compiler: riscv32-linux-gcc (GCC) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot cppcheck warnings: (new ones prefixed by >>) >> drivers/staging/emxx_udc/emxx_udc.c:839:9: warning: Variable 'result' is >> reassigned a value before the old one has been used. [redundantAssignment] result = length & ~(u32)0x03; ^ drivers/staging/emxx_udc/emxx_udc.c:796:0: note: Variable 'result' is reassigned a value before the old one has been used. int result = -EINVAL; ^ drivers/staging/emxx_udc/emxx_udc.c:839:9: note: Variable 'result' is reassigned a value before the old one has been used. result = length & ~(u32)0x03; ^ drivers/staging/emxx_udc/emxx_udc.c:1045:9: warning: Variable 'result' is reassigned a value before the old one has been used. [redundantAssignment] result = i_write_length & ~(u32)0x3; ^ drivers/staging/emxx_udc/emxx_udc.c:990:0: note: Variable 'result' is reassigned a value before the old one has been used. int result = -EINVAL; ^ drivers/staging/emxx_udc/emxx_udc.c:1045:9: note: Variable 'result' is reassigned a value before the old one has been used. result = i_write_length & ~(u32)0x3; ^ >> drivers/staging/emxx_udc/emxx_udc.c:1307:16: warning: Variable 'ep->stalled' >> is reassigned a value before the old one has been used. [redundantAssignment] ep->stalled = false; ^ drivers/staging/emxx_udc/emxx_udc.c:1292:16: note: Variable 'ep->stalled' is reassigned a value before the old one has been used. ep->stalled = false; ^ drivers/staging/emxx_udc/emxx_udc.c:1307:16: note: Variable 'ep->stalled' is reassigned a value before the old one has been used. ep->stalled = false; ^ >> drivers/staging/emxx_udc/emxx_udc.c:3094:9: warning: Variable 'status' is >> reassigned a value before the old one has been used. [redundantAssignment] status = devm_request_irq(>dev, irq, _nbu2ss_udc_irq, ^ drivers/staging/emxx_udc/emxx_udc.c:3076:0: note: Variable 'status' is reassigned a value before the old one has been used. int status = -ENODEV; ^ drivers/staging/emxx_udc/emxx_udc.c:3094:9: note: Variable 'status' is reassigned a value before the old one has been used. status = devm_request_irq(>dev, irq, _nbu2ss_udc_irq, ^ >> drivers/staging/emxx_udc/emxx_udc.c:2095:48: warning: Uninitialized >> variable: ep [uninitvar] list_for_each_entry(ep, >gadget.ep_list, ep.ep_list) { ^ # https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git/commit/?id=fbcfdfab4a2c4ec5e2195929528506fec39388f3 git remote add staging https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git git fetch --no-tags staging staging-testing git checkout fbcfdfab4a2c4ec5e2195929528506fec39388f3 vim +/result +839 drivers/staging/emxx_udc/emxx_udc.c 33aa8d45a4fea3 Magnus Damm 2014-06-06 785 33aa8d45a4fea3 Magnus Damm 2014-06-06 786 /*-*/ e2d34dfdffcfd1 Cristian Sicilia2018-11-17 787 static int _nbu2ss_out_dma(struct nbu2ss_udc *udc, struct nbu2ss_req *req, e2d34dfdffcfd1 Cristian Sicilia2018-11-17 788 u32 num, u32 length) 33aa8d45a4fea3 Magnus Damm 2014-06-06 789 { 5a012f67cbcb20 Alexis Lothoré 2017-05-10 790 dma_addr_t p_buffer; 33aa8d45a4fea3 Magnus Damm 2014-06-06 791 u32 mpkt; 33aa8d45a4fea3 Magnus Damm 2014-06-06 792 u32 lmpkt; 33aa8d45a4fea3 Magnus Damm 2014-06-06 793 u32 dmacnt; 33aa8d45a4fea3 Magnus Damm 2014-06-06 794 u32 burst = 1; 33aa8d45a4fea3 Magnus Damm 2014-06-06 795 u32 data; 33aa8d45a4fea3 Magnus Damm 2014-06-06 796 int result = -EINVAL; 64407f6e7d158e Carmeli Tamir 2018-11-07 797 struct fc_regs __iomem *preg = udc->p_regs; 33aa8d45a4fea3 Magnus Damm 2014-06-06 798 33aa8d45a4fea3 Magnus Damm 2014-06-06 799 if (req->dma_flag) 33aa8d45a4fea3 Magnus Damm 2014-06-06 800 return 1; /* DMA is forwarded */ 33aa8d45a4fea3 Magnus Damm 2014-06-06 801 8b77d94e69c33f Saiyam Doshi2019-09-08 802 req->dma_flag = true; 5a012f67cbcb20 Alexis Lothoré 2017-05-10 803 p_buffer = req->req.dma; 5a012f67cbcb20 Alexis Lothoré 2017-05-10 804 p_buffer += req->req.actual; 33aa8d45a4fea3 Magnus Damm 2014-06-06 805 33aa8d45a4fea3 Magnus