From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752595AbbDBQZS (ORCPT ); Thu, 2 Apr 2015 12:25:18 -0400 Received: from smtprelay0026.hostedemail.com ([216.40.44.26]:52648 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750876AbbDBQZP (ORCPT ); Thu, 2 Apr 2015 12:25:15 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::::::::::::,RULES_HIT:41:355:379:541:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2895:2898:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:3874:5007:6119:6261:8660:10004:10400:10848:11026:11473:11658:11914:12517:12519:13069:13148:13230:13255:13311:13357:21080,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 X-HE-Tag: pump79_84cc5b417803c X-Filterd-Recvd-Size: 3212 Date: Thu, 2 Apr 2015 12:25:11 -0400 From: Steven Rostedt To: Namhyung Kim Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Andrew Morton , Masami Hiramatsu , Mathieu Desnoyers , Guilherme Cox , Tony Luck , Xie XiuQi Subject: Re: [RFC][PATCH 06/17 v3] tracing: Add TRACE_DEFINE_ENUM() macro to map enums to their values Message-ID: <20150402122511.058a27ce@gandalf.local.home> In-Reply-To: <20150402095745.14441ae1@gandalf.local.home> References: <20150402015648.249824760@goodmis.org> <20150402020940.953163951@goodmis.org> <20150402074740.GA23913@sejong> <20150402092708.0616199d@gandalf.local.home> <20150402095745.14441ae1@gandalf.local.home> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; 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 I updated the function to handle structures that were saved as well. Just in case something like REC->my_enum does not get converted. Also, I found that I never needed to decrement the pointer for those locations that I did so. Here's the new function: static void update_event_printk(struct ftrace_event_call *call, struct trace_enum_map *map) { char *ptr; int quote = 0; int len = strlen(map->enum_string); for (ptr = call->print_fmt; *ptr; ptr++) { if (*ptr == '\\') { ptr++; /* paranoid */ if (!*ptr) break; continue; } if (*ptr == '"') { quote ^= 1; continue; } if (quote) continue; if (isdigit(*ptr)) { /* skip numbers */ do { ptr++; /* Check for alpha chars like ULL */ } while (isalnum(*ptr)); /* * A number must have some kind of delimiter after * it, and we can ignore that too. */ continue; } if (isalpha(*ptr) || *ptr == '_') { if (strncmp(map->enum_string, ptr, len) == 0 && !isalnum(ptr[len]) && ptr[len] != '_') { ptr = enum_replace(ptr, map, len); /* Hmm, enum string smaller than value */ if (WARN_ON_ONCE(!ptr)) return; /* * No need to decrement here, as enum_replace() * returns the pointer to the character passed * the enum, and two enums can not be placed * back to back without something in between. * We can skip that something in between. */ continue; } skip_more: do { ptr++; } while (isalnum(*ptr) || *ptr == '_'); /* * If what comes after this variable is a '.' or * '->' then we can continue to ignore that string. */ if (*ptr == '.' || (ptr[0] == '-' && ptr[1] == '>')) { ptr += *ptr == '.' ? 1 : 2; goto skip_more; } /* * Once again, we can skip the delimiter that came * after the string. */ continue; } } }