Commit c4dc775f53136cd6af8f88bce67cce9b42751768
Committed by
Ingo Molnar
1 parent
afdf1a404e
Exists in
master
and in
7 other branches
perf tools: Remove all char * typecasts and use const in prototype
The (char *) for all the static strings was a fix for the symptom and not the disease. The real issue was that the function prototypes needed to be declared "const char *". Signed-off-by: Steven Rostedt <srostedt@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> LKML-Reference: <20091014194400.635935008@goodmis.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Showing 1 changed file with 61 additions and 61 deletions Side-by-side Diff
tools/perf/util/trace-event-parse.c
... | ... | @@ -685,10 +685,10 @@ |
685 | 685 | { |
686 | 686 | char *token; |
687 | 687 | |
688 | - if (read_expected(EVENT_ITEM, (char *)"name") < 0) | |
688 | + if (read_expected(EVENT_ITEM, "name") < 0) | |
689 | 689 | return NULL; |
690 | 690 | |
691 | - if (read_expected(EVENT_OP, (char *)":") < 0) | |
691 | + if (read_expected(EVENT_OP, ":") < 0) | |
692 | 692 | return NULL; |
693 | 693 | |
694 | 694 | if (read_expect_type(EVENT_ITEM, &token) < 0) |
695 | 695 | |
... | ... | @@ -706,10 +706,10 @@ |
706 | 706 | char *token; |
707 | 707 | int id; |
708 | 708 | |
709 | - if (read_expected_item(EVENT_ITEM, (char *)"ID") < 0) | |
709 | + if (read_expected_item(EVENT_ITEM, "ID") < 0) | |
710 | 710 | return -1; |
711 | 711 | |
712 | - if (read_expected(EVENT_OP, (char *)":") < 0) | |
712 | + if (read_expected(EVENT_OP, ":") < 0) | |
713 | 713 | return -1; |
714 | 714 | |
715 | 715 | if (read_expect_type(EVENT_ITEM, &token) < 0) |
... | ... | @@ -759,7 +759,7 @@ |
759 | 759 | |
760 | 760 | count++; |
761 | 761 | |
762 | - if (test_type_token(type, token, EVENT_ITEM, (char *)"field")) | |
762 | + if (test_type_token(type, token, EVENT_ITEM, "field")) | |
763 | 763 | goto fail; |
764 | 764 | free_token(token); |
765 | 765 | |
... | ... | @@ -774,7 +774,7 @@ |
774 | 774 | type = read_token(&token); |
775 | 775 | } |
776 | 776 | |
777 | - if (test_type_token(type, token, EVENT_OP, (char *)":") < 0) | |
777 | + if (test_type_token(type, token, EVENT_OP, ":") < 0) | |
778 | 778 | return -1; |
779 | 779 | |
780 | 780 | if (read_expect_type(EVENT_ITEM, &token) < 0) |
781 | 781 | |
782 | 782 | |
... | ... | @@ -892,14 +892,14 @@ |
892 | 892 | field->flags |= FIELD_IS_DYNAMIC; |
893 | 893 | } |
894 | 894 | |
895 | - if (test_type_token(type, token, EVENT_OP, (char *)";")) | |
895 | + if (test_type_token(type, token, EVENT_OP, ";")) | |
896 | 896 | goto fail; |
897 | 897 | free_token(token); |
898 | 898 | |
899 | - if (read_expected(EVENT_ITEM, (char *)"offset") < 0) | |
899 | + if (read_expected(EVENT_ITEM, "offset") < 0) | |
900 | 900 | goto fail_expect; |
901 | 901 | |
902 | - if (read_expected(EVENT_OP, (char *)":") < 0) | |
902 | + if (read_expected(EVENT_OP, ":") < 0) | |
903 | 903 | goto fail_expect; |
904 | 904 | |
905 | 905 | if (read_expect_type(EVENT_ITEM, &token)) |
906 | 906 | |
907 | 907 | |
... | ... | @@ -907,13 +907,13 @@ |
907 | 907 | field->offset = strtoul(token, NULL, 0); |
908 | 908 | free_token(token); |
909 | 909 | |
910 | - if (read_expected(EVENT_OP, (char *)";") < 0) | |
910 | + if (read_expected(EVENT_OP, ";") < 0) | |
911 | 911 | goto fail_expect; |
912 | 912 | |
913 | - if (read_expected(EVENT_ITEM, (char *)"size") < 0) | |
913 | + if (read_expected(EVENT_ITEM, "size") < 0) | |
914 | 914 | goto fail_expect; |
915 | 915 | |
916 | - if (read_expected(EVENT_OP, (char *)":") < 0) | |
916 | + if (read_expected(EVENT_OP, ":") < 0) | |
917 | 917 | goto fail_expect; |
918 | 918 | |
919 | 919 | if (read_expect_type(EVENT_ITEM, &token)) |
920 | 920 | |
921 | 921 | |
... | ... | @@ -921,18 +921,18 @@ |
921 | 921 | field->size = strtoul(token, NULL, 0); |
922 | 922 | free_token(token); |
923 | 923 | |
924 | - if (read_expected(EVENT_OP, (char *)";") < 0) | |
924 | + if (read_expected(EVENT_OP, ";") < 0) | |
925 | 925 | goto fail_expect; |
926 | 926 | |
927 | 927 | type = read_token(&token); |
928 | 928 | if (type != EVENT_NEWLINE) { |
929 | 929 | /* newer versions of the kernel have a "signed" type */ |
930 | - if (test_type_token(type, token, EVENT_ITEM, (char *)"signed")) | |
930 | + if (test_type_token(type, token, EVENT_ITEM, "signed")) | |
931 | 931 | goto fail; |
932 | 932 | |
933 | 933 | free_token(token); |
934 | 934 | |
935 | - if (read_expected(EVENT_OP, (char *)":") < 0) | |
935 | + if (read_expected(EVENT_OP, ":") < 0) | |
936 | 936 | goto fail_expect; |
937 | 937 | |
938 | 938 | if (read_expect_type(EVENT_ITEM, &token)) |
... | ... | @@ -941,7 +941,7 @@ |
941 | 941 | /* add signed type */ |
942 | 942 | |
943 | 943 | free_token(token); |
944 | - if (read_expected(EVENT_OP, (char *)";") < 0) | |
944 | + if (read_expected(EVENT_OP, ";") < 0) | |
945 | 945 | goto fail_expect; |
946 | 946 | |
947 | 947 | if (read_expect_type(EVENT_NEWLINE, &token)) |
948 | 948 | |
... | ... | @@ -970,10 +970,10 @@ |
970 | 970 | char *token; |
971 | 971 | int ret; |
972 | 972 | |
973 | - if (read_expected_item(EVENT_ITEM, (char *)"format") < 0) | |
973 | + if (read_expected_item(EVENT_ITEM, "format") < 0) | |
974 | 974 | return -1; |
975 | 975 | |
976 | - if (read_expected(EVENT_OP, (char *)":") < 0) | |
976 | + if (read_expected(EVENT_OP, ":") < 0) | |
977 | 977 | return -1; |
978 | 978 | |
979 | 979 | if (read_expect_type(EVENT_NEWLINE, &token)) |
... | ... | @@ -1033,7 +1033,7 @@ |
1033 | 1033 | |
1034 | 1034 | *tok = NULL; |
1035 | 1035 | type = process_arg(event, left, &token); |
1036 | - if (test_type_token(type, token, EVENT_OP, (char *)":")) | |
1036 | + if (test_type_token(type, token, EVENT_OP, ":")) | |
1037 | 1037 | goto out_free; |
1038 | 1038 | |
1039 | 1039 | arg->op.op = token; |
... | ... | @@ -1065,7 +1065,7 @@ |
1065 | 1065 | |
1066 | 1066 | *tok = NULL; |
1067 | 1067 | type = process_arg(event, arg, &token); |
1068 | - if (test_type_token(type, token, EVENT_OP, (char *)"]")) | |
1068 | + if (test_type_token(type, token, EVENT_OP, "]")) | |
1069 | 1069 | goto out_free; |
1070 | 1070 | |
1071 | 1071 | top->op.right = arg; |
... | ... | @@ -1287,7 +1287,7 @@ |
1287 | 1287 | char *field; |
1288 | 1288 | char *token; |
1289 | 1289 | |
1290 | - if (read_expected(EVENT_OP, (char *)"->") < 0) | |
1290 | + if (read_expected(EVENT_OP, "->") < 0) | |
1291 | 1291 | return EVENT_ERROR; |
1292 | 1292 | |
1293 | 1293 | if (read_expect_type(EVENT_ITEM, &token) < 0) |
1294 | 1294 | |
... | ... | @@ -1447,14 +1447,14 @@ |
1447 | 1447 | do { |
1448 | 1448 | free_token(token); |
1449 | 1449 | type = read_token_item(&token); |
1450 | - if (test_type_token(type, token, EVENT_OP, (char *)"{")) | |
1450 | + if (test_type_token(type, token, EVENT_OP, "{")) | |
1451 | 1451 | break; |
1452 | 1452 | |
1453 | 1453 | arg = malloc_or_die(sizeof(*arg)); |
1454 | 1454 | |
1455 | 1455 | free_token(token); |
1456 | 1456 | type = process_arg(event, arg, &token); |
1457 | - if (test_type_token(type, token, EVENT_DELIM, (char *)",")) | |
1457 | + if (test_type_token(type, token, EVENT_DELIM, ",")) | |
1458 | 1458 | goto out_free; |
1459 | 1459 | |
1460 | 1460 | field = malloc_or_die(sizeof(*field)); |
... | ... | @@ -1465,7 +1465,7 @@ |
1465 | 1465 | |
1466 | 1466 | free_token(token); |
1467 | 1467 | type = process_arg(event, arg, &token); |
1468 | - if (test_type_token(type, token, EVENT_OP, (char *)"}")) | |
1468 | + if (test_type_token(type, token, EVENT_OP, "}")) | |
1469 | 1469 | goto out_free; |
1470 | 1470 | |
1471 | 1471 | value = arg_eval(arg); |
1472 | 1472 | |
... | ... | @@ -1500,13 +1500,13 @@ |
1500 | 1500 | memset(arg, 0, sizeof(*arg)); |
1501 | 1501 | arg->type = PRINT_FLAGS; |
1502 | 1502 | |
1503 | - if (read_expected_item(EVENT_DELIM, (char *)"(") < 0) | |
1503 | + if (read_expected_item(EVENT_DELIM, "(") < 0) | |
1504 | 1504 | return EVENT_ERROR; |
1505 | 1505 | |
1506 | 1506 | field = malloc_or_die(sizeof(*field)); |
1507 | 1507 | |
1508 | 1508 | type = process_arg(event, field, &token); |
1509 | - if (test_type_token(type, token, EVENT_DELIM, (char *)",")) | |
1509 | + if (test_type_token(type, token, EVENT_DELIM, ",")) | |
1510 | 1510 | goto out_free; |
1511 | 1511 | |
1512 | 1512 | arg->flags.field = field; |
1513 | 1513 | |
... | ... | @@ -1517,11 +1517,11 @@ |
1517 | 1517 | type = read_token_item(&token); |
1518 | 1518 | } |
1519 | 1519 | |
1520 | - if (test_type_token(type, token, EVENT_DELIM, (char *)",")) | |
1520 | + if (test_type_token(type, token, EVENT_DELIM, ",")) | |
1521 | 1521 | goto out_free; |
1522 | 1522 | |
1523 | 1523 | type = process_fields(event, &arg->flags.flags, &token); |
1524 | - if (test_type_token(type, token, EVENT_DELIM, (char *)")")) | |
1524 | + if (test_type_token(type, token, EVENT_DELIM, ")")) | |
1525 | 1525 | goto out_free; |
1526 | 1526 | |
1527 | 1527 | free_token(token); |
1528 | 1528 | |
1529 | 1529 | |
... | ... | @@ -1543,19 +1543,19 @@ |
1543 | 1543 | memset(arg, 0, sizeof(*arg)); |
1544 | 1544 | arg->type = PRINT_SYMBOL; |
1545 | 1545 | |
1546 | - if (read_expected_item(EVENT_DELIM, (char *)"(") < 0) | |
1546 | + if (read_expected_item(EVENT_DELIM, "(") < 0) | |
1547 | 1547 | return EVENT_ERROR; |
1548 | 1548 | |
1549 | 1549 | field = malloc_or_die(sizeof(*field)); |
1550 | 1550 | |
1551 | 1551 | type = process_arg(event, field, &token); |
1552 | - if (test_type_token(type, token, EVENT_DELIM, (char *)",")) | |
1552 | + if (test_type_token(type, token, EVENT_DELIM, ",")) | |
1553 | 1553 | goto out_free; |
1554 | 1554 | |
1555 | 1555 | arg->symbol.field = field; |
1556 | 1556 | |
1557 | 1557 | type = process_fields(event, &arg->symbol.symbols, &token); |
1558 | - if (test_type_token(type, token, EVENT_DELIM, (char *)")")) | |
1558 | + if (test_type_token(type, token, EVENT_DELIM, ")")) | |
1559 | 1559 | goto out_free; |
1560 | 1560 | |
1561 | 1561 | free_token(token); |
... | ... | @@ -1585,7 +1585,7 @@ |
1585 | 1585 | if (type == EVENT_ERROR) |
1586 | 1586 | return EVENT_ERROR; |
1587 | 1587 | |
1588 | - if (test_type_token(type, token, EVENT_DELIM, (char *)")")) { | |
1588 | + if (test_type_token(type, token, EVENT_DELIM, ")")) { | |
1589 | 1589 | free_token(token); |
1590 | 1590 | return EVENT_ERROR; |
1591 | 1591 | } |
... | ... | @@ -1626,7 +1626,7 @@ |
1626 | 1626 | enum event_type type; |
1627 | 1627 | char *token; |
1628 | 1628 | |
1629 | - if (read_expected(EVENT_DELIM, (char *)"(") < 0) | |
1629 | + if (read_expected(EVENT_DELIM, "(") < 0) | |
1630 | 1630 | return EVENT_ERROR; |
1631 | 1631 | |
1632 | 1632 | if (read_expect_type(EVENT_ITEM, &token) < 0) |
... | ... | @@ -1636,7 +1636,7 @@ |
1636 | 1636 | arg->string.string = token; |
1637 | 1637 | arg->string.offset = -1; |
1638 | 1638 | |
1639 | - if (read_expected(EVENT_DELIM, (char *)")") < 0) | |
1639 | + if (read_expected(EVENT_DELIM, ")") < 0) | |
1640 | 1640 | return EVENT_ERROR; |
1641 | 1641 | |
1642 | 1642 | type = read_token(&token); |
1643 | 1643 | |
1644 | 1644 | |
... | ... | @@ -1775,13 +1775,13 @@ |
1775 | 1775 | char *token; |
1776 | 1776 | int ret; |
1777 | 1777 | |
1778 | - if (read_expected_item(EVENT_ITEM, (char *)"print") < 0) | |
1778 | + if (read_expected_item(EVENT_ITEM, "print") < 0) | |
1779 | 1779 | return -1; |
1780 | 1780 | |
1781 | - if (read_expected(EVENT_ITEM, (char *)"fmt") < 0) | |
1781 | + if (read_expected(EVENT_ITEM, "fmt") < 0) | |
1782 | 1782 | return -1; |
1783 | 1783 | |
1784 | - if (read_expected(EVENT_OP, (char *)":") < 0) | |
1784 | + if (read_expected(EVENT_OP, ":") < 0) | |
1785 | 1785 | return -1; |
1786 | 1786 | |
1787 | 1787 | if (read_expect_type(EVENT_DQUOTE, &token) < 0) |
... | ... | @@ -1811,8 +1811,8 @@ |
1811 | 1811 | token = cat; |
1812 | 1812 | goto concat; |
1813 | 1813 | } |
1814 | - | |
1815 | - if (test_type_token(type, token, EVENT_DELIM, (char *)",")) | |
1814 | + | |
1815 | + if (test_type_token(type, token, EVENT_DELIM, ",")) | |
1816 | 1816 | goto fail; |
1817 | 1817 | |
1818 | 1818 | free_token(token); |
... | ... | @@ -1931,7 +1931,7 @@ |
1931 | 1931 | } |
1932 | 1932 | |
1933 | 1933 | static int __parse_common(void *data, int *size, int *offset, |
1934 | - char *name) | |
1934 | + const char *name) | |
1935 | 1935 | { |
1936 | 1936 | int ret; |
1937 | 1937 | |
... | ... | @@ -1949,7 +1949,7 @@ |
1949 | 1949 | static int type_size; |
1950 | 1950 | |
1951 | 1951 | return __parse_common(data, &type_size, &type_offset, |
1952 | - (char *)"common_type"); | |
1952 | + "common_type"); | |
1953 | 1953 | } |
1954 | 1954 | |
1955 | 1955 | static int parse_common_pid(void *data) |
... | ... | @@ -1958,7 +1958,7 @@ |
1958 | 1958 | static int pid_size; |
1959 | 1959 | |
1960 | 1960 | return __parse_common(data, &pid_size, &pid_offset, |
1961 | - (char *)"common_pid"); | |
1961 | + "common_pid"); | |
1962 | 1962 | } |
1963 | 1963 | |
1964 | 1964 | static int parse_common_pc(void *data) |
... | ... | @@ -1967,7 +1967,7 @@ |
1967 | 1967 | static int pc_size; |
1968 | 1968 | |
1969 | 1969 | return __parse_common(data, &pc_size, &pc_offset, |
1970 | - (char *)"common_preempt_count"); | |
1970 | + "common_preempt_count"); | |
1971 | 1971 | } |
1972 | 1972 | |
1973 | 1973 | static int parse_common_flags(void *data) |
... | ... | @@ -1976,7 +1976,7 @@ |
1976 | 1976 | static int flags_size; |
1977 | 1977 | |
1978 | 1978 | return __parse_common(data, &flags_size, &flags_offset, |
1979 | - (char *)"common_flags"); | |
1979 | + "common_flags"); | |
1980 | 1980 | } |
1981 | 1981 | |
1982 | 1982 | static int parse_common_lock_depth(void *data) |
... | ... | @@ -1986,7 +1986,7 @@ |
1986 | 1986 | int ret; |
1987 | 1987 | |
1988 | 1988 | ret = __parse_common(data, &ld_size, &ld_offset, |
1989 | - (char *)"common_lock_depth"); | |
1989 | + "common_lock_depth"); | |
1990 | 1990 | if (ret < 0) |
1991 | 1991 | return -1; |
1992 | 1992 | |
1993 | 1993 | |
1994 | 1994 | |
... | ... | @@ -3049,15 +3049,15 @@ |
3049 | 3049 | } |
3050 | 3050 | } |
3051 | 3051 | |
3052 | -static void parse_header_field(char *field, | |
3052 | +static void parse_header_field(const char *field, | |
3053 | 3053 | int *offset, int *size) |
3054 | 3054 | { |
3055 | 3055 | char *token; |
3056 | 3056 | int type; |
3057 | 3057 | |
3058 | - if (read_expected(EVENT_ITEM, (char *)"field") < 0) | |
3058 | + if (read_expected(EVENT_ITEM, "field") < 0) | |
3059 | 3059 | return; |
3060 | - if (read_expected(EVENT_OP, (char *)":") < 0) | |
3060 | + if (read_expected(EVENT_OP, ":") < 0) | |
3061 | 3061 | return; |
3062 | 3062 | |
3063 | 3063 | /* type */ |
3064 | 3064 | |
3065 | 3065 | |
3066 | 3066 | |
3067 | 3067 | |
3068 | 3068 | |
3069 | 3069 | |
... | ... | @@ -3067,27 +3067,27 @@ |
3067 | 3067 | |
3068 | 3068 | if (read_expected(EVENT_ITEM, field) < 0) |
3069 | 3069 | return; |
3070 | - if (read_expected(EVENT_OP, (char *)";") < 0) | |
3070 | + if (read_expected(EVENT_OP, ";") < 0) | |
3071 | 3071 | return; |
3072 | - if (read_expected(EVENT_ITEM, (char *)"offset") < 0) | |
3072 | + if (read_expected(EVENT_ITEM, "offset") < 0) | |
3073 | 3073 | return; |
3074 | - if (read_expected(EVENT_OP, (char *)":") < 0) | |
3074 | + if (read_expected(EVENT_OP, ":") < 0) | |
3075 | 3075 | return; |
3076 | 3076 | if (read_expect_type(EVENT_ITEM, &token) < 0) |
3077 | 3077 | goto fail; |
3078 | 3078 | *offset = atoi(token); |
3079 | 3079 | free_token(token); |
3080 | - if (read_expected(EVENT_OP, (char *)";") < 0) | |
3080 | + if (read_expected(EVENT_OP, ";") < 0) | |
3081 | 3081 | return; |
3082 | - if (read_expected(EVENT_ITEM, (char *)"size") < 0) | |
3082 | + if (read_expected(EVENT_ITEM, "size") < 0) | |
3083 | 3083 | return; |
3084 | - if (read_expected(EVENT_OP, (char *)":") < 0) | |
3084 | + if (read_expected(EVENT_OP, ":") < 0) | |
3085 | 3085 | return; |
3086 | 3086 | if (read_expect_type(EVENT_ITEM, &token) < 0) |
3087 | 3087 | goto fail; |
3088 | 3088 | *size = atoi(token); |
3089 | 3089 | free_token(token); |
3090 | - if (read_expected(EVENT_OP, (char *)";") < 0) | |
3090 | + if (read_expected(EVENT_OP, ";") < 0) | |
3091 | 3091 | return; |
3092 | 3092 | type = read_token(&token); |
3093 | 3093 | if (type != EVENT_NEWLINE) { |
3094 | 3094 | |
3095 | 3095 | |
... | ... | @@ -3095,19 +3095,19 @@ |
3095 | 3095 | if (type != EVENT_ITEM) |
3096 | 3096 | goto fail; |
3097 | 3097 | |
3098 | - if (strcmp(token, (char *)"signed") != 0) | |
3098 | + if (strcmp(token, "signed") != 0) | |
3099 | 3099 | goto fail; |
3100 | 3100 | |
3101 | 3101 | free_token(token); |
3102 | 3102 | |
3103 | - if (read_expected(EVENT_OP, (char *)":") < 0) | |
3103 | + if (read_expected(EVENT_OP, ":") < 0) | |
3104 | 3104 | return; |
3105 | 3105 | |
3106 | 3106 | if (read_expect_type(EVENT_ITEM, &token)) |
3107 | 3107 | goto fail; |
3108 | 3108 | |
3109 | 3109 | free_token(token); |
3110 | - if (read_expected(EVENT_OP, (char *)";") < 0) | |
3110 | + if (read_expected(EVENT_OP, ";") < 0) | |
3111 | 3111 | return; |
3112 | 3112 | |
3113 | 3113 | if (read_expect_type(EVENT_NEWLINE, &token)) |
3114 | 3114 | |
3115 | 3115 | |
... | ... | @@ -3121,11 +3121,11 @@ |
3121 | 3121 | { |
3122 | 3122 | init_input_buf(buf, size); |
3123 | 3123 | |
3124 | - parse_header_field((char *)"timestamp", &header_page_ts_offset, | |
3124 | + parse_header_field("timestamp", &header_page_ts_offset, | |
3125 | 3125 | &header_page_ts_size); |
3126 | - parse_header_field((char *)"commit", &header_page_size_offset, | |
3126 | + parse_header_field("commit", &header_page_size_offset, | |
3127 | 3127 | &header_page_size_size); |
3128 | - parse_header_field((char *)"data", &header_page_data_offset, | |
3128 | + parse_header_field("data", &header_page_data_offset, | |
3129 | 3129 | &header_page_data_size); |
3130 | 3130 | |
3131 | 3131 | return 0; |