From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932763AbdIHXF0 (ORCPT ); Fri, 8 Sep 2017 19:05:26 -0400 Received: from www62.your-server.de ([213.133.104.62]:33233 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756939AbdIHXFZ (ORCPT ); Fri, 8 Sep 2017 19:05:25 -0400 Message-ID: <59B32231.9090406@iogearbox.net> Date: Sat, 09 Sep 2017 01:05:21 +0200 From: Daniel Borkmann User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Alexei Starovoitov , Thomas Meyer CC: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, shuah@kernel.org Subject: Re: [PATCH] selftests/bpf: Make bpf_util work on uniprocessor systems References: <20170908111923.27434-1-thomas@m3y3r.de> <20170908230155.esge2mctk5d5g7gb@ast-mbp> In-Reply-To: <20170908230155.esge2mctk5d5g7gb@ast-mbp> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/09/2017 01:01 AM, Alexei Starovoitov wrote: > On Fri, Sep 08, 2017 at 01:19:23PM +0200, Thomas Meyer wrote: >> The current implementation fails to work on uniprocessor systems. >> Fix the parser to also handle the uniprocessor case. >> >> Signed-off-by: Thomas Meyer > > Thanks for the fix. lgtm > Acked-by: Alexei Starovoitov Looks good from here as well: Acked-by: Daniel Borkmann > This time it's ok to go via selftest tree, but next time please use net-next/net > to avoid conflicts. +1 > Thanks > >> --- >> tools/testing/selftests/bpf/bpf_util.h | 17 +++++++++-------- >> 1 file changed, 9 insertions(+), 8 deletions(-) >> >> diff --git a/tools/testing/selftests/bpf/bpf_util.h b/tools/testing/selftests/bpf/bpf_util.h >> index 20ecbaa0d85d..6c53a8906eff 100644 >> --- a/tools/testing/selftests/bpf/bpf_util.h >> +++ b/tools/testing/selftests/bpf/bpf_util.h >> @@ -12,6 +12,7 @@ static inline unsigned int bpf_num_possible_cpus(void) >> unsigned int start, end, possible_cpus = 0; >> char buff[128]; >> FILE *fp; >> + int n; >> >> fp = fopen(fcpu, "r"); >> if (!fp) { >> @@ -20,17 +21,17 @@ static inline unsigned int bpf_num_possible_cpus(void) >> } >> >> while (fgets(buff, sizeof(buff), fp)) { >> - if (sscanf(buff, "%u-%u", &start, &end) == 2) { >> - possible_cpus = start == 0 ? end + 1 : 0; >> - break; >> + n = sscanf(buff, "%u-%u", &start, &end); >> + if (n == 0) { >> + printf("Failed to retrieve # possible CPUs!\n"); >> + exit(1); >> + } else if (n == 1) { >> + end = start; >> } >> + possible_cpus = start == 0 ? end + 1 : 0; >> + break; >> } >> - >> fclose(fp); >> - if (!possible_cpus) { >> - printf("Failed to retrieve # possible CPUs!\n"); >> - exit(1); >> - } >> >> return possible_cpus; >> } >> -- >> 2.11.0 >>