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;
                }
        }
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to