Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPICA: Common: Enhance acpi_getopt() to improve portability

This patch enhances acpi_getopt() by converting the standard C library
invocations into portable ACPI string APIs and acpi_log_error() to improve
portability. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Lv Zheng and committed by
Rafael J. Wysocki
a92e9577 3c9349c9

+14 -9
+2
drivers/acpi/acpica/acutils.h
··· 210 210 211 211 acpi_size acpi_ut_strlen(const char *string); 212 212 213 + char *acpi_ut_strchr(const char *string, int ch); 214 + 213 215 char *acpi_ut_strcpy(char *dst_string, const char *src_string); 214 216 215 217 char *acpi_ut_strncpy(char *dst_string,
+4
include/acpi/actypes.h
··· 1254 1254 #define ACPI_FILE_BEGIN 0x01 1255 1255 #define ACPI_FILE_END 0x02 1256 1256 1257 + /* Definitions of getopt */ 1258 + 1259 + #define ACPI_OPT_END -1 1260 + 1257 1261 #endif /* __ACTYPES_H__ */
+6 -8
tools/power/acpi/common/getopt.c
··· 51 51 * "f|" - Option has required single-char sub-options 52 52 */ 53 53 54 - #include <stdio.h> 55 - #include <string.h> 56 54 #include <acpi/acpi.h> 57 55 #include "accommon.h" 58 56 #include "acapps.h" 59 57 60 58 #define ACPI_OPTION_ERROR(msg, badchar) \ 61 - if (acpi_gbl_opterr) {fprintf (stderr, "%s%c\n", msg, badchar);} 59 + if (acpi_gbl_opterr) {acpi_log_error ("%s%c\n", msg, badchar);} 62 60 63 61 int acpi_gbl_opterr = 1; 64 62 int acpi_gbl_optind = 1; ··· 111 113 * PARAMETERS: argc, argv - from main 112 114 * opts - options info list 113 115 * 114 - * RETURN: Option character or EOF 116 + * RETURN: Option character or ACPI_OPT_END 115 117 * 116 118 * DESCRIPTION: Get the next option 117 119 * ··· 126 128 if (acpi_gbl_optind >= argc || 127 129 argv[acpi_gbl_optind][0] != '-' || 128 130 argv[acpi_gbl_optind][1] == '\0') { 129 - return (EOF); 130 - } else if (strcmp(argv[acpi_gbl_optind], "--") == 0) { 131 + return (ACPI_OPT_END); 132 + } else if (ACPI_STRCMP(argv[acpi_gbl_optind], "--") == 0) { 131 133 acpi_gbl_optind++; 132 - return (EOF); 134 + return (ACPI_OPT_END); 133 135 } 134 136 } 135 137 ··· 140 142 /* Make sure that the option is legal */ 141 143 142 144 if (current_char == ':' || 143 - (opts_ptr = strchr(opts, current_char)) == NULL) { 145 + (opts_ptr = ACPI_STRCHR(opts, current_char)) == NULL) { 144 146 ACPI_OPTION_ERROR("Illegal option: -", current_char); 145 147 146 148 if (argv[acpi_gbl_optind][++current_char_ptr] == '\0') {
+2 -1
tools/power/acpi/tools/acpidump/apmain.c
··· 166 166 167 167 /* Command line options */ 168 168 169 - while ((j = acpi_getopt(argc, argv, AP_SUPPORTED_OPTIONS)) != EOF) 169 + while ((j = 170 + acpi_getopt(argc, argv, AP_SUPPORTED_OPTIONS)) != ACPI_OPT_END) 170 171 switch (j) { 171 172 /* 172 173 * Global options