From: Carlos Santos <casantos@redhat.com>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [PATCH] util/cacheinfo: fix crash when compiling with uClibc
Date: Mon, 20 Jan 2020 15:26:54 -0300 [thread overview]
Message-ID: <CAC1VKkMVTWq+xsKRXmsA-U7Uwwq_6iXrFuDP9zdJEoFthg374A@mail.gmail.com> (raw)
In-Reply-To: <48f341e2-5844-2929-1c38-4ecd26ed8546@linaro.org>
On Thu, Jan 16, 2020 at 9:04 PM Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> On 12/16/19 1:18 AM, Carlos Santos wrote:
> > On Thu, Oct 17, 2019 at 8:06 PM Carlos Santos <casantos@redhat.com> wrote:
> >>
> >> On Thu, Oct 17, 2019 at 9:47 AM Peter Maydell <peter.maydell@linaro.org> wrote:
> >>>
> >>> On Thu, 17 Oct 2019 at 13:39, <casantos@redhat.com> wrote:
> >>>>
> >>>> From: Carlos Santos <casantos@redhat.com>
> >>>>
> >>>> uClibc defines _SC_LEVEL1_ICACHE_LINESIZE and _SC_LEVEL1_DCACHE_LINESIZE
> >>>> but the corresponding sysconf calls returns -1, which is a valid result,
> >>>> meaning that the limit is indeterminate.
> >>>>
> >>>> Handle this situation using the fallback values instead of crashing due
> >>>> to an assertion failure.
> >>>>
> >>>> Signed-off-by: Carlos Santos <casantos@redhat.com>
> >>>> ---
> >>>> util/cacheinfo.c | 10 ++++++++--
> >>>> 1 file changed, 8 insertions(+), 2 deletions(-)
> >>>>
> >>>> diff --git a/util/cacheinfo.c b/util/cacheinfo.c
> >>>> index ea6f3e99bf..d94dc6adc8 100644
> >>>> --- a/util/cacheinfo.c
> >>>> +++ b/util/cacheinfo.c
> >>>> @@ -93,10 +93,16 @@ static void sys_cache_info(int *isize, int *dsize)
> >>>> static void sys_cache_info(int *isize, int *dsize)
> >>>> {
> >>>> # ifdef _SC_LEVEL1_ICACHE_LINESIZE
> >>>> - *isize = sysconf(_SC_LEVEL1_ICACHE_LINESIZE);
> >>>> + int tmp_isize = (int) sysconf(_SC_LEVEL1_ICACHE_LINESIZE);
> >>>
> >>> Do we need the cast here ?
> >>
> >> It's there to remind the reader that a type coercion may occur, since
> >> sysconf() returns a long and isize is an int.
> >>
> >>>> + if (tmp_isize > 0) {
> >>>> + *isize = tmp_isize;
> >>>> + }
> >>>> # endif
> >>>> # ifdef _SC_LEVEL1_DCACHE_LINESIZE
> >>>> - *dsize = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
> >>>> + int tmp_dsize = (int) sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
> >>>> + if (tmp_dsize > 0) {
> >>>> + *dsize = tmp_dsize;
> >>>> + }
> >>>> # endif
> >>>> }
> >>>> #endif /* sys_cache_info */
> >>>> --
> >>>
> >>> thanks
> >>> -- PMM
> >>
> >> --
> >> Carlos Santos
> >> Senior Software Maintenance Engineer
> >> Red Hat
> >> casantos@redhat.com T: +55-11-3534-6186
> >
> > Hi,
> >
> > Any chance to have this merged for Christmas? :-)
>
> No, but it's queued now. ;-)
>
>
> r~
>
Ah, Easter, perhaps. :-)
--
Carlos Santos
Senior Software Maintenance Engineer
Red Hat
casantos@redhat.com T: +55-11-3534-6186
prev parent reply other threads:[~2020-01-20 18:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-17 12:37 [PATCH] util/cacheinfo: fix crash when compiling with uClibc casantos
2019-10-17 12:47 ` Peter Maydell
2019-10-17 23:06 ` Carlos Santos
2019-12-16 11:18 ` Carlos Santos
2020-01-17 0:04 ` Richard Henderson
2020-01-20 18:26 ` Carlos Santos [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAC1VKkMVTWq+xsKRXmsA-U7Uwwq_6iXrFuDP9zdJEoFthg374A@mail.gmail.com \
--to=casantos@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).