hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/scripts/kconfig/expr.c
....@@ -1,8 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3
- * Released under the terms of the GNU GPL v2.0.
44 */
55
6
+#include <ctype.h>
7
+#include <errno.h>
68 #include <stdio.h>
79 #include <stdlib.h>
810 #include <string.h>
....@@ -11,7 +13,6 @@
1113
1214 #define DEBUG_EXPR 0
1315
14
-static int expr_eq(struct expr *e1, struct expr *e2);
1516 static struct expr *expr_eliminate_yn(struct expr *e);
1617
1718 struct expr *expr_alloc_symbol(struct symbol *sym)
....@@ -248,7 +249,7 @@
248249 * equals some operand in the other (operands do not need to appear in the same
249250 * order), recursively.
250251 */
251
-static int expr_eq(struct expr *e1, struct expr *e2)
252
+int expr_eq(struct expr *e1, struct expr *e2)
252253 {
253254 int res, old_count;
254255
....@@ -987,7 +988,6 @@
987988 k_string,
988989 k_signed,
989990 k_unsigned,
990
- k_invalid
991991 };
992992
993993 union string_value {
....@@ -1018,13 +1018,10 @@
10181018 val->u = strtoull(str, &tail, 16);
10191019 kind = k_unsigned;
10201020 break;
1021
- case S_STRING:
1022
- case S_UNKNOWN:
1021
+ default:
10231022 val->s = strtoll(str, &tail, 0);
10241023 kind = k_signed;
10251024 break;
1026
- default:
1027
- return k_invalid;
10281025 }
10291026 return !errno && !*tail && tail > str && isxdigit(tail[-1])
10301027 ? kind : k_string;
....@@ -1080,13 +1077,7 @@
10801077
10811078 if (k1 == k_string || k2 == k_string)
10821079 res = strcmp(str1, str2);
1083
- else if (k1 == k_invalid || k2 == k_invalid) {
1084
- if (e->type != E_EQUAL && e->type != E_UNEQUAL) {
1085
- printf("Cannot compare \"%s\" and \"%s\"\n", str1, str2);
1086
- return no;
1087
- }
1088
- res = strcmp(str1, str2);
1089
- } else if (k1 == k_unsigned || k2 == k_unsigned)
1080
+ else if (k1 == k_unsigned || k2 == k_unsigned)
10901081 res = (lval.u > rval.u) - (lval.u < rval.u);
10911082 else /* if (k1 == k_signed && k2 == k_signed) */
10921083 res = (lval.s > rval.s) - (lval.s < rval.s);