[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YooFpVGuDoyfoQPS@smile.fi.intel.com>
Date: Sun, 22 May 2022 12:43:01 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Waiman Long <longman@...hat.com>
Cc: Maninder Singh <maninder1.s@...sung.com>, keescook@...omium.org,
pmladek@...e.com, bcain@...cinc.com, mpe@...erman.id.au,
benh@...nel.crashing.org, paulus@...ba.org, hca@...ux.ibm.com,
gor@...ux.ibm.com, agordeev@...ux.ibm.com,
borntraeger@...ux.ibm.com, svens@...ux.ibm.com, satishkh@...co.com,
sebaddel@...co.com, kartilak@...co.com, jejb@...ux.ibm.com,
martin.petersen@...cle.com, mcgrof@...nel.org,
jason.wessel@...driver.com, daniel.thompson@...aro.org,
dianders@...omium.org, naveen.n.rao@...ux.ibm.com,
anil.s.keshavamurthy@...el.com, davem@...emloft.net,
mhiramat@...nel.org, peterz@...radead.org, mingo@...hat.com,
will@...nel.org, boqun.feng@...il.com, rostedt@...dmis.org,
senozhatsky@...omium.org, linux@...musvillemoes.dk,
akpm@...ux-foundation.org, arnd@...db.de,
linux-hexagon@...r.kernel.org, linux-kernel@...r.kernel.org,
linuxppc-dev@...ts.ozlabs.org, linux-s390@...r.kernel.org,
linux-scsi@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-modules@...r.kernel.org,
kgdb-bugreport@...ts.sourceforge.net, v.narang@...sung.com,
onkarnath.1@...sung.com
Subject: Re: [PATCH 1/5] kallsyms: pass buffer size in sprint_* APIs
On Fri, May 20, 2022 at 03:52:01PM -0400, Waiman Long wrote:
> On 5/20/22 04:36, Maninder Singh wrote:
...
> > - sprint_symbol(sym, addr);
> > + sprint_symbol(sym, KSYM_SYMBOL_LEN, addr);
>
> Instead of hardcoding KSYM_SYMBOL_LEN everywhere, will it better to hide it
> like this:
>
> extern int __sprint_symbol(char *buffer, size_t size, unsigned long
> address);
> #define sprint_symbol(buf, addr) __sprint_symbol(buf,
> sizeof(buf), addr)
>
> Or you can use sizeof(buf) directly instead of KSYM_SYMBOL_LEN.
This assumes that buf is defined as char [], which might be not always the
case. If you are going with the macro, than ARRAY_SIZE() seems appropriate
to perform a check against the above mentioned constraint.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists