From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Shevchenko Subject: Re: [PATCH 1/5] kallsyms: pass buffer size in sprint_* APIs Date: Sun, 22 May 2022 12:43:01 +0300 Message-ID: References: <20220520083701.2610975-1-maninder1.s@samsung.com> <20220520083701.2610975-2-maninder1.s@samsung.com> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653212596; x=1684748596; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=J1uRxreTk2vcgBP+Mv+o2kjbzDSrcYl4+WqXF1IBsU8=; b=XLdFBFgoTxYniEX/Tgn4Zn+eawD1UL5Q246madtsbUR93j8vJQJxGjGC DSmUBRbgrz1vTIcybBLpuT4IxU6VLCyv0S4x5GShKFED4IgCb7Oq0htuq JJzS5PP8EuSazctx0FafiAytjCG4YkwDjJ5d6xursevIyPMC/3+XZEYQ1 CU5NPbb35V0FZkTgnA4oN/pGVkgMvKLyufNbocRKD+0rRB1WL6DbGOvvc E+3c6wF9N2x1TKJgnidh20sMU/i4ItCB0LdyCiNVDifDZTBXvtFyhs6rO nm7O4P7n9m8b3D3NeSXjti3nte6hgIqoLVXtK5ZhGD9Ga2Gu4dtfRq+KA Q==; Content-Disposition: inline In-Reply-To: List-ID: Content-Type: text/plain; charset="iso-8859-1" To: Waiman Long Cc: Maninder Singh , keescook@chromium.org, pmladek@suse.com, bcain@quicinc.com, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, satishkh@cisco.com, sebaddel@cisco.com, kartilak@cisco.com, jejb@linux.ibm.com, martin.petersen@oracle.com, mcgrof@kernel.org, jason.wessel@windriver.com, daniel.thompson@linaro.org, dianders@chromium.org, naveen.n.rao@linux.ibm.com, anil.s.keshavamurthy@intel.com, davem@davemloft.net, mhiramat@kernel.org, peterz@infradead.org, mingo@redhat.com, will@kernel.org, boqun.feng@gmail.com, rostedt@goodmis.org, senozhatsky@chromium.org, linux@rasmusvillemoes.dk, akpm@linux-foundation.org, arnd@arndb.de, linux- 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); >=20 > Instead of hardcoding KSYM_SYMBOL_LEN everywhere, will it better to hide = it > like this: >=20 > =A0=A0=A0=A0=A0=A0=A0 extern int __sprint_symbol(char *buffer, size_t siz= e, unsigned long > address); > =A0=A0=A0=A0=A0=A0=A0 #define sprint_symbol(buf, addr)=A0=A0=A0=A0=A0=A0= =A0 __sprint_symbol(buf, > sizeof(buf), addr) >=20 > 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. --=20 With Best Regards, Andy Shevchenko