linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] misc: use DIV_ROUND_UP macro to do calculation
@ 2020-12-22 13:33 Zheng Yongjun
  2020-12-22 17:11 ` Daniel Thompson
  2020-12-29  2:41 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Zheng Yongjun @ 2020-12-22 13:33 UTC (permalink / raw)
  To: jason.wessel, daniel.thompson, kgdb-bugreport, linux-kernel
  Cc: dianders, Zheng Yongjun

Don't open-code DIV_ROUND_UP() kernel macro.

Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
 drivers/misc/kgdbts.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
index 945701bce553..cd086921a792 100644
--- a/drivers/misc/kgdbts.c
+++ b/drivers/misc/kgdbts.c
@@ -139,9 +139,8 @@ static int restart_from_top_after_write;
 static int sstep_state;
 
 /* Storage for the registers, in GDB format. */
-static unsigned long kgdbts_gdb_regs[(NUMREGBYTES +
-					sizeof(unsigned long) - 1) /
-					sizeof(unsigned long)];
+static unsigned long kgdbts_gdb_regs[DIV_ROUND_UP(NUMREGBYTES,
+				     sizeof(unsigned long)i)];
 static struct pt_regs kgdbts_regs;
 
 /* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
-- 
2.22.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] misc: use DIV_ROUND_UP macro to do calculation
  2020-12-22 13:33 [PATCH -next] misc: use DIV_ROUND_UP macro to do calculation Zheng Yongjun
@ 2020-12-22 17:11 ` Daniel Thompson
  2020-12-29  2:41 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Thompson @ 2020-12-22 17:11 UTC (permalink / raw)
  To: Zheng Yongjun; +Cc: jason.wessel, kgdb-bugreport, linux-kernel, dianders

On Tue, Dec 22, 2020 at 09:33:44PM +0800, Zheng Yongjun wrote:
> Don't open-code DIV_ROUND_UP() kernel macro.
> 
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
> ---
>  drivers/misc/kgdbts.c | 5 ++---

Arguably this patch should have kgdbts in the Subject line.


>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
> index 945701bce553..cd086921a792 100644
> --- a/drivers/misc/kgdbts.c
> +++ b/drivers/misc/kgdbts.c
> @@ -139,9 +139,8 @@ static int restart_from_top_after_write;
>  static int sstep_state;
>  
>  /* Storage for the registers, in GDB format. */
> -static unsigned long kgdbts_gdb_regs[(NUMREGBYTES +
> -					sizeof(unsigned long) - 1) /
> -					sizeof(unsigned long)];
> +static unsigned long kgdbts_gdb_regs[DIV_ROUND_UP(NUMREGBYTES,
> +				     sizeof(unsigned long)i)];

How was this patch tested? This code does not look like it is
compilable.


Daniel.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] misc: use DIV_ROUND_UP macro to do calculation
  2020-12-22 13:33 [PATCH -next] misc: use DIV_ROUND_UP macro to do calculation Zheng Yongjun
  2020-12-22 17:11 ` Daniel Thompson
@ 2020-12-29  2:41 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2020-12-29  2:41 UTC (permalink / raw)
  To: Zheng Yongjun, jason.wessel, daniel.thompson, kgdb-bugreport,
	linux-kernel
  Cc: kbuild-all, dianders, Zheng Yongjun

[-- Attachment #1: Type: text/plain, Size: 4240 bytes --]

Hi Zheng,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20201222]

url:    https://github.com/0day-ci/linux/commits/Zheng-Yongjun/misc-use-DIV_ROUND_UP-macro-to-do-calculation/20201222-220138
base:    6c3eb1b174c07bcaa927003e8bc91e81ab1d5a9e
config: microblaze-randconfig-r022-20201221 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/5b74808b6866933e6adc4d6475429e77c3ccbb23
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Zheng-Yongjun/misc-use-DIV_ROUND_UP-macro-to-do-calculation/20201222-220138
        git checkout 5b74808b6866933e6adc4d6475429e77c3ccbb23
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=microblaze 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from include/vdso/const.h:5,
                    from include/linux/const.h:4,
                    from include/linux/bits.h:5,
                    from include/linux/bitops.h:6,
                    from include/linux/kernel.h:11,
                    from drivers/misc/kgdbts.c:85:
>> drivers/misc/kgdbts.c:143:31: error: expected ')' before 'i'
     143 |          sizeof(unsigned long)i)];
         |                               ^
   include/uapi/linux/const.h:34:46: note: in definition of macro '__KERNEL_DIV_ROUND_UP'
      34 | #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
         |                                              ^
   drivers/misc/kgdbts.c:142:38: note: in expansion of macro 'DIV_ROUND_UP'
     142 | static unsigned long kgdbts_gdb_regs[DIV_ROUND_UP(NUMREGBYTES,
         |                                      ^~~~~~~~~~~~
   include/uapi/linux/const.h:34:45: note: to match this '('
      34 | #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
         |                                             ^
   include/linux/math.h:36:22: note: in expansion of macro '__KERNEL_DIV_ROUND_UP'
      36 | #define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP
         |                      ^~~~~~~~~~~~~~~~~~~~~
   drivers/misc/kgdbts.c:142:38: note: in expansion of macro 'DIV_ROUND_UP'
     142 | static unsigned long kgdbts_gdb_regs[DIV_ROUND_UP(NUMREGBYTES,
         |                                      ^~~~~~~~~~~~
>> drivers/misc/kgdbts.c:143:31: error: expected ')' before 'i'
     143 |          sizeof(unsigned long)i)];
         |                               ^
   include/uapi/linux/const.h:34:57: note: in definition of macro '__KERNEL_DIV_ROUND_UP'
      34 | #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
         |                                                         ^
   drivers/misc/kgdbts.c:142:38: note: in expansion of macro 'DIV_ROUND_UP'
     142 | static unsigned long kgdbts_gdb_regs[DIV_ROUND_UP(NUMREGBYTES,
         |                                      ^~~~~~~~~~~~
   include/uapi/linux/const.h:34:56: note: to match this '('
      34 | #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
         |                                                        ^
   include/linux/math.h:36:22: note: in expansion of macro '__KERNEL_DIV_ROUND_UP'
      36 | #define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP
         |                      ^~~~~~~~~~~~~~~~~~~~~
   drivers/misc/kgdbts.c:142:38: note: in expansion of macro 'DIV_ROUND_UP'
     142 | static unsigned long kgdbts_gdb_regs[DIV_ROUND_UP(NUMREGBYTES,
         |                                      ^~~~~~~~~~~~


vim +143 drivers/misc/kgdbts.c

   140	
   141	/* Storage for the registers, in GDB format. */
   142	static unsigned long kgdbts_gdb_regs[DIV_ROUND_UP(NUMREGBYTES,
 > 143					     sizeof(unsigned long)i)];
   144	static struct pt_regs kgdbts_regs;
   145	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35984 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-29  2:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-22 13:33 [PATCH -next] misc: use DIV_ROUND_UP macro to do calculation Zheng Yongjun
2020-12-22 17:11 ` Daniel Thompson
2020-12-29  2:41 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).