[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YEvibJFnQhCncaqr@otcwcpicx3.sc.intel.com>
Date: Fri, 12 Mar 2021 21:51:40 +0000
From: Fenghua Yu <fenghua.yu@...el.com>
To: Babu Moger <babu.moger@....com>
Cc: Shuah Khan <shuah@...nel.org>, Tony Luck <tony.luck@...el.com>,
Reinette Chatre <reinette.chatre@...el.com>,
linux-kselftest <linux-kselftest@...r.kernel.org>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v5 02/21] selftests/resctrl: Fix compilation issues for
global variables
Hi, Babu,
On Fri, Mar 12, 2021 at 01:08:31PM -0600, Babu Moger wrote:
> > From: Fenghua Yu <fenghua.yu@...el.com>
> > Taking a closer look at the usage of these variables reveals that these
> > variables are used only locally to functions such as cqm_resctrl_val()
>
> %s/ locally to functions/locally in two functions
OK. Will change it.
> > -int get_cbm_mask(char *cache_type)
> > +int get_cbm_mask(char *cache_type, char *cbm_mask)
> > {
> > char cbm_mask_path[1024];
> > FILE *fp;
> >
> > + if (!cbm_mask)
> > + return -1;
>
> Can cbm_mask be NULL? I see it is statically allocated.
> Or should this be if (!(*cbm_mask))? Or did I miss something.
This is a sanity checking. Although current callers do pass statically
allocated cbm_mask to the parameter, future callers may incorrectly pass
un-allocated cbm_mask to the parameter and may cause segmentation fault
without the sanity checking. To debug this kind of issue, the sanity
checking will be very helpful.
So I would keep this sanity checking.
Thanks.
-Fenghua
Powered by blists - more mailing lists