From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751676AbcGOQCk (ORCPT ); Fri, 15 Jul 2016 12:02:40 -0400 Received: from smtprelay0213.hostedemail.com ([216.40.44.213]:44433 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751302AbcGOQCi (ORCPT ); Fri, 15 Jul 2016 12:02:38 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 50,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:967:973:982:988:989:1260:1263:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2525:2553:2560:2563:2682:2685:2859:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:5007:6261:7875:7901:7903:8957:9025:10004:10400:10848:10967:11026:11232:11257:11657:11658:11914:12043:12438:12517:12519:12555:12740:13069:13138:13231:13311:13357:13439:14106:14181:14659:14721:21080:30012:30054:30070:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:7,LUA_SUMMARY:none X-HE-Tag: laugh01_506628e5a891b X-Filterd-Recvd-Size: 3017 Date: Fri, 15 Jul 2016 12:02:31 -0400 From: Steven Rostedt To: Jiri Pirko Cc: Jiri Olsa , Arnaldo Carvalho de Melo , lkml , David Ahern , Ingo Molnar , Namhyung Kim , Peter Zijlstra Subject: Re: [PATCH 1/3] perf script python: Fix string vs byte array resolving Message-ID: <20160715120231.4539632f@gandalf.local.home> In-Reply-To: <20160715155110.GF1983@nanopsycho.orion> References: <1468567797-27564-1-git-send-email-jolsa@kernel.org> <1468567797-27564-2-git-send-email-jolsa@kernel.org> <20160715155110.GF1983@nanopsycho.orion> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 15 Jul 2016 17:51:10 +0200 Jiri Pirko wrote: > Fri, Jul 15, 2016 at 09:29:55AM CEST, jolsa@kernel.org wrote: > >Jirka reported that python code returns all arrays as strings. > >This makes impossible to get all items for byte array tracepoint > >field containing 0x00 value item. > > > >Fixing this by scanning full length of the array and returning > >it as PyByteArray object in case non printable byte is found. > > > >Cc: Steven Rostedt (Red Hat) > >Cc: Jiri Pirko > >Link: http://lkml.kernel.org/n/tip-22f4vhhz5uytegkggy1on8u3@git.kernel.org > >Signed-off-by: Jiri Olsa > >--- > > .../util/scripting-engines/trace-event-python.c | 37 ++++++++++++++++++---- > > 1 file changed, 31 insertions(+), 6 deletions(-) > > > >diff --git a/tools/perf/util/scripting-engines/trace-event-python.c b/tools/perf/util/scripting-engines/trace-event-python.c > >index 6ac6b7a33f42..1bc995de5a6d 100644 > >--- a/tools/perf/util/scripting-engines/trace-event-python.c > >+++ b/tools/perf/util/scripting-engines/trace-event-python.c > >@@ -386,6 +386,19 @@ exit: > > return pylist; > > } > > > >+static int is_printable_array(char *p, unsigned int len) > >+{ > >+ unsigned int i; > >+ > >+ if (p[len - 1] == 0) > >+ len--; > >+ > >+ for (i = 0; i < len - 1; i++) > >+ if (!isprint(p[i]) && !isspace(p[i])) > >+ return 0; > > > for "AA\1\0" this returns "1" although that should return "0". > > orig len 4 > decremented len 3 > for: > 0 1 > > index 2 would not be inspected. Or am I missing something? > > I think that the for check should be "i < len" Yes it should be. I think we got the two solutions mixed up. With the above len--, it should be i < len, but when we did the check for zero at the end, we needed the i < len - 1 -- Steve