From: Nathan Lynch <nathanl@linux.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: [PATCH] selftests/powerpc: Add a test of sigreturn vs VDSO
Date: Fri, 06 Mar 2020 12:31:12 -0600 [thread overview]
Message-ID: <87k13xjpxr.fsf@linux.ibm.com> (raw)
In-Reply-To: <87mu8tjq7l.fsf@linux.ibm.com>
Nathan Lynch <nathanl@linux.ibm.com> writes:
> Michael Ellerman <mpe@ellerman.id.au> writes:
>
>> +static int search_proc_maps(char *needle, unsigned long *low, unsigned long *high)
>
> ^^ const?
>
>> +{
>> + unsigned long start, end;
>> + static char buf[4096];
>> + char name[128];
>> + FILE *f;
>> + int rc = -1;
>> +
>> + f = fopen("/proc/self/maps", "r");
>> + if (!f) {
>> + perror("fopen");
>> + return -1;
>> + }
>> +
>> + while (fgets(buf, sizeof(buf), f)) {
>> + rc = sscanf(buf, "%lx-%lx %*c%*c%*c%*c %*x %*d:%*d %*d %127s\n",
>> + &start, &end, name);
>
> I suspect it doesn't matter in practice for this particular test, but
> since this looks like a generally useful function that could gain users
> in the future: does this spuriously fail if the matching line straddles
> a 4096-byte boundary? Maybe fscanf(3) should be used instead?
Or maybe I should read the fgets man page more closely :-)
"Reading stops after an EOF or a newline."
Sorry for the noise.
next prev parent reply other threads:[~2020-03-06 18:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-04 11:04 [PATCH] selftests/powerpc: Add a test of sigreturn vs VDSO Michael Ellerman
2020-03-06 18:25 ` Nathan Lynch
2020-03-06 18:31 ` Nathan Lynch [this message]
2020-03-26 12:04 ` Michael Ellerman
2020-03-26 12:06 ` Michael Ellerman
2021-06-17 9:00 ` Christophe Leroy
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=87k13xjpxr.fsf@linux.ibm.com \
--to=nathanl@linux.ibm.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=mpe@ellerman.id.au \
/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).