aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2015-07-23 00:53:49 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2015-07-23 17:09:08 -0400
commit276291962ebf43abebb491ddcd922009de9fde4b (patch)
tree14dafffc9a84d5f2a2ece4e2d8ce6235b6032d99 /drivers/acpi
parent5a4f0693a586d73a65ccc7959e81a5618de265fe (diff)
ACPICA: Cleanup use of all non-ANSI local C library functions
ACPICA commit 7c490c28a18b435c543c6b410e7e7c2131fccc78 ACPICA implements all non-ANSI functions locally. However, there are sometimes two or more versions of the same function throughout the ACPICA code. This change fixes this. Adds a new file, utilities/utnonansi.c Link: https://github.com/acpica/acpica/commit/7c490c28 Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/acpica/Makefile1
-rw-r--r--drivers/acpi/acpica/acmacros.h4
-rw-r--r--drivers/acpi/acpica/acutils.h23
-rw-r--r--drivers/acpi/acpica/utnonansi.c380
-rw-r--r--drivers/acpi/acpica/utstring.c342
5 files changed, 396 insertions, 354 deletions
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index 9f30ed7b1a07..fedcc16b56cc 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -165,6 +165,7 @@ acpi-y += \
165 utmath.o \ 165 utmath.o \
166 utmisc.o \ 166 utmisc.o \
167 utmutex.o \ 167 utmutex.o \
168 utnonansi.o \
168 utobject.o \ 169 utobject.o \
169 utosi.o \ 170 utosi.o \
170 utownerid.o \ 171 utownerid.o \
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index c240bdf824f2..19d40c6c1f32 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -220,6 +220,10 @@
220#define ACPI_MUL_32(a) _ACPI_MUL(a, 5) 220#define ACPI_MUL_32(a) _ACPI_MUL(a, 5)
221#define ACPI_MOD_32(a) _ACPI_MOD(a, 32) 221#define ACPI_MOD_32(a) _ACPI_MOD(a, 32)
222 222
223/* Test for ASCII character */
224
225#define ACPI_IS_ASCII(c) ((c) < 0x80)
226
223/* 227/*
224 * Rounding macros (Power of two boundaries only) 228 * Rounding macros (Power of two boundaries only)
225 */ 229 */
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 6de0d3573037..566ff4df02fd 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -167,6 +167,17 @@ struct acpi_pkg_info {
167#define DB_QWORD_DISPLAY 8 167#define DB_QWORD_DISPLAY 8
168 168
169/* 169/*
170 * utnonansi - Non-ANSI C library functions
171 */
172void acpi_ut_strupr(char *src_string);
173
174void acpi_ut_strlwr(char *src_string);
175
176int acpi_ut_stricmp(char *string1, char *string2);
177
178acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer);
179
180/*
170 * utglobal - Global data structures and procedures 181 * utglobal - Global data structures and procedures
171 */ 182 */
172acpi_status acpi_ut_init_globals(void); 183acpi_status acpi_ut_init_globals(void);
@@ -205,8 +216,6 @@ acpi_status acpi_ut_hardware_initialize(void);
205 216
206void acpi_ut_subsystem_shutdown(void); 217void acpi_ut_subsystem_shutdown(void);
207 218
208#define ACPI_IS_ASCII(c) ((c) < 0x80)
209
210/* 219/*
211 * utcopy - Object construction and conversion interfaces 220 * utcopy - Object construction and conversion interfaces
212 */ 221 */
@@ -567,16 +576,6 @@ acpi_ut_get_resource_end_tag(union acpi_operand_object *obj_desc, u8 **end_tag);
567/* 576/*
568 * utstring - String and character utilities 577 * utstring - String and character utilities
569 */ 578 */
570void acpi_ut_strupr(char *src_string);
571
572#ifdef ACPI_ASL_COMPILER
573void acpi_ut_strlwr(char *src_string);
574
575int acpi_ut_stricmp(char *string1, char *string2);
576#endif
577
578acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer);
579
580void acpi_ut_print_string(char *string, u16 max_length); 579void acpi_ut_print_string(char *string, u16 max_length);
581 580
582#if defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP 581#if defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP
diff --git a/drivers/acpi/acpica/utnonansi.c b/drivers/acpi/acpica/utnonansi.c
new file mode 100644
index 000000000000..1d5f6b17b766
--- /dev/null
+++ b/drivers/acpi/acpica/utnonansi.c
@@ -0,0 +1,380 @@
1/*******************************************************************************
2 *
3 * Module Name: utnonansi - Non-ansi C library functions
4 *
5 ******************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2015, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46
47#define _COMPONENT ACPI_UTILITIES
48ACPI_MODULE_NAME("utnonansi")
49
50/*
51 * Non-ANSI C library functions - strlwr, strupr, stricmp, and a 64-bit
52 * version of strtoul.
53 */
54/*******************************************************************************
55 *
56 * FUNCTION: acpi_ut_strlwr (strlwr)
57 *
58 * PARAMETERS: src_string - The source string to convert
59 *
60 * RETURN: None
61 *
62 * DESCRIPTION: Convert a string to lowercase
63 *
64 ******************************************************************************/
65void acpi_ut_strlwr(char *src_string)
66{
67 char *string;
68
69 ACPI_FUNCTION_ENTRY();
70
71 if (!src_string) {
72 return;
73 }
74
75 /* Walk entire string, lowercasing the letters */
76
77 for (string = src_string; *string; string++) {
78 *string = (char)tolower((int)*string);
79 }
80}
81
82/*******************************************************************************
83 *
84 * FUNCTION: acpi_ut_strupr (strupr)
85 *
86 * PARAMETERS: src_string - The source string to convert
87 *
88 * RETURN: None
89 *
90 * DESCRIPTION: Convert a string to uppercase
91 *
92 ******************************************************************************/
93
94void acpi_ut_strupr(char *src_string)
95{
96 char *string;
97
98 ACPI_FUNCTION_ENTRY();
99
100 if (!src_string) {
101 return;
102 }
103
104 /* Walk entire string, uppercasing the letters */
105
106 for (string = src_string; *string; string++) {
107 *string = (char)toupper((int)*string);
108 }
109}
110
111/******************************************************************************
112 *
113 * FUNCTION: acpi_ut_stricmp (stricmp)
114 *
115 * PARAMETERS: string1 - first string to compare
116 * string2 - second string to compare
117 *
118 * RETURN: int that signifies string relationship. Zero means strings
119 * are equal.
120 *
121 * DESCRIPTION: Case-insensitive string compare. Implementation of the
122 * non-ANSI stricmp function.
123 *
124 ******************************************************************************/
125
126int acpi_ut_stricmp(char *string1, char *string2)
127{
128 int c1;
129 int c2;
130
131 do {
132 c1 = tolower((int)*string1);
133 c2 = tolower((int)*string2);
134
135 string1++;
136 string2++;
137 }
138 while ((c1 == c2) && (c1));
139
140 return (c1 - c2);
141}
142
143/*******************************************************************************
144 *
145 * FUNCTION: acpi_ut_strtoul64
146 *
147 * PARAMETERS: string - Null terminated string
148 * base - Radix of the string: 16 or ACPI_ANY_BASE;
149 * ACPI_ANY_BASE means 'in behalf of to_integer'
150 * ret_integer - Where the converted integer is returned
151 *
152 * RETURN: Status and Converted value
153 *
154 * DESCRIPTION: Convert a string into an unsigned value. Performs either a
155 * 32-bit or 64-bit conversion, depending on the current mode
156 * of the interpreter.
157 *
158 * NOTE: Does not support Octal strings, not needed.
159 *
160 ******************************************************************************/
161
162acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer)
163{
164 u32 this_digit = 0;
165 u64 return_value = 0;
166 u64 quotient;
167 u64 dividend;
168 u32 to_integer_op = (base == ACPI_ANY_BASE);
169 u32 mode32 = (acpi_gbl_integer_byte_width == 4);
170 u8 valid_digits = 0;
171 u8 sign_of0x = 0;
172 u8 term = 0;
173
174 ACPI_FUNCTION_TRACE_STR(ut_stroul64, string);
175
176 switch (base) {
177 case ACPI_ANY_BASE:
178 case 16:
179
180 break;
181
182 default:
183
184 /* Invalid Base */
185
186 return_ACPI_STATUS(AE_BAD_PARAMETER);
187 }
188
189 if (!string) {
190 goto error_exit;
191 }
192
193 /* Skip over any white space in the buffer */
194
195 while ((*string) && (isspace((int)*string) || *string == '\t')) {
196 string++;
197 }
198
199 if (to_integer_op) {
200 /*
201 * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'.
202 * We need to determine if it is decimal or hexadecimal.
203 */
204 if ((*string == '0') && (tolower((int)*(string + 1)) == 'x')) {
205 sign_of0x = 1;
206 base = 16;
207
208 /* Skip over the leading '0x' */
209 string += 2;
210 } else {
211 base = 10;
212 }
213 }
214
215 /* Any string left? Check that '0x' is not followed by white space. */
216
217 if (!(*string) || isspace((int)*string) || *string == '\t') {
218 if (to_integer_op) {
219 goto error_exit;
220 } else {
221 goto all_done;
222 }
223 }
224
225 /*
226 * Perform a 32-bit or 64-bit conversion, depending upon the current
227 * execution mode of the interpreter
228 */
229 dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX;
230
231 /* Main loop: convert the string to a 32- or 64-bit integer */
232
233 while (*string) {
234 if (isdigit((int)*string)) {
235
236 /* Convert ASCII 0-9 to Decimal value */
237
238 this_digit = ((u8)*string) - '0';
239 } else if (base == 10) {
240
241 /* Digit is out of range; possible in to_integer case only */
242
243 term = 1;
244 } else {
245 this_digit = (u8)toupper((int)*string);
246 if (isxdigit((int)this_digit)) {
247
248 /* Convert ASCII Hex char to value */
249
250 this_digit = this_digit - 'A' + 10;
251 } else {
252 term = 1;
253 }
254 }
255
256 if (term) {
257 if (to_integer_op) {
258 goto error_exit;
259 } else {
260 break;
261 }
262 } else if ((valid_digits == 0) && (this_digit == 0)
263 && !sign_of0x) {
264
265 /* Skip zeros */
266 string++;
267 continue;
268 }
269
270 valid_digits++;
271
272 if (sign_of0x
273 && ((valid_digits > 16)
274 || ((valid_digits > 8) && mode32))) {
275 /*
276 * This is to_integer operation case.
277 * No any restrictions for string-to-integer conversion,
278 * see ACPI spec.
279 */
280 goto error_exit;
281 }
282
283 /* Divide the digit into the correct position */
284
285 (void)acpi_ut_short_divide((dividend - (u64)this_digit),
286 base, &quotient, NULL);
287
288 if (return_value > quotient) {
289 if (to_integer_op) {
290 goto error_exit;
291 } else {
292 break;
293 }
294 }
295
296 return_value *= base;
297 return_value += this_digit;
298 string++;
299 }
300
301 /* All done, normal exit */
302
303all_done:
304
305 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
306 ACPI_FORMAT_UINT64(return_value)));
307
308 *ret_integer = return_value;
309 return_ACPI_STATUS(AE_OK);
310
311error_exit:
312 /* Base was set/validated above */
313
314 if (base == 10) {
315 return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT);
316 } else {
317 return_ACPI_STATUS(AE_BAD_HEX_CONSTANT);
318 }
319}
320
321#if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION)
322/*******************************************************************************
323 *
324 * FUNCTION: acpi_ut_safe_strcpy, acpi_ut_safe_strcat, acpi_ut_safe_strncat
325 *
326 * PARAMETERS: Adds a "DestSize" parameter to each of the standard string
327 * functions. This is the size of the Destination buffer.
328 *
329 * RETURN: TRUE if the operation would overflow the destination buffer.
330 *
331 * DESCRIPTION: Safe versions of standard Clib string functions. Ensure that
332 * the result of the operation will not overflow the output string
333 * buffer.
334 *
335 * NOTE: These functions are typically only helpful for processing
336 * user input and command lines. For most ACPICA code, the
337 * required buffer length is precisely calculated before buffer
338 * allocation, so the use of these functions is unnecessary.
339 *
340 ******************************************************************************/
341
342u8 acpi_ut_safe_strcpy(char *dest, acpi_size dest_size, char *source)
343{
344
345 if (strlen(source) >= dest_size) {
346 return (TRUE);
347 }
348
349 strcpy(dest, source);
350 return (FALSE);
351}
352
353u8 acpi_ut_safe_strcat(char *dest, acpi_size dest_size, char *source)
354{
355
356 if ((strlen(dest) + strlen(source)) >= dest_size) {
357 return (TRUE);
358 }
359
360 strcat(dest, source);
361 return (FALSE);
362}
363
364u8
365acpi_ut_safe_strncat(char *dest,
366 acpi_size dest_size,
367 char *source, acpi_size max_transfer_length)
368{
369 acpi_size actual_transfer_length;
370
371 actual_transfer_length = ACPI_MIN(max_transfer_length, strlen(source));
372
373 if ((strlen(dest) + actual_transfer_length) >= dest_size) {
374 return (TRUE);
375 }
376
377 strncat(dest, source, max_transfer_length);
378 return (FALSE);
379}
380#endif
diff --git a/drivers/acpi/acpica/utstring.c b/drivers/acpi/acpica/utstring.c
index 8f3c883dfe0e..4ddd105d9741 100644
--- a/drivers/acpi/acpica/utstring.c
+++ b/drivers/acpi/acpica/utstring.c
@@ -48,286 +48,6 @@
48#define _COMPONENT ACPI_UTILITIES 48#define _COMPONENT ACPI_UTILITIES
49ACPI_MODULE_NAME("utstring") 49ACPI_MODULE_NAME("utstring")
50 50
51/*
52 * Non-ANSI C library functions - strlwr, strupr, stricmp, and a 64-bit
53 * version of strtoul.
54 */
55#ifdef ACPI_ASL_COMPILER
56/*******************************************************************************
57 *
58 * FUNCTION: acpi_ut_strlwr (strlwr)
59 *
60 * PARAMETERS: src_string - The source string to convert
61 *
62 * RETURN: None
63 *
64 * DESCRIPTION: Convert string to lowercase
65 *
66 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
67 *
68 ******************************************************************************/
69void acpi_ut_strlwr(char *src_string)
70{
71 char *string;
72
73 ACPI_FUNCTION_ENTRY();
74
75 if (!src_string) {
76 return;
77 }
78
79 /* Walk entire string, lowercasing the letters */
80
81 for (string = src_string; *string; string++) {
82 *string = (char)tolower((int)*string);
83 }
84
85 return;
86}
87
88/******************************************************************************
89 *
90 * FUNCTION: acpi_ut_stricmp (stricmp)
91 *
92 * PARAMETERS: string1 - first string to compare
93 * string2 - second string to compare
94 *
95 * RETURN: int that signifies string relationship. Zero means strings
96 * are equal.
97 *
98 * DESCRIPTION: Implementation of the non-ANSI stricmp function (compare
99 * strings with no case sensitivity)
100 *
101 ******************************************************************************/
102
103int acpi_ut_stricmp(char *string1, char *string2)
104{
105 int c1;
106 int c2;
107
108 do {
109 c1 = tolower((int)*string1);
110 c2 = tolower((int)*string2);
111
112 string1++;
113 string2++;
114 }
115 while ((c1 == c2) && (c1));
116
117 return (c1 - c2);
118}
119#endif
120
121/*******************************************************************************
122 *
123 * FUNCTION: acpi_ut_strupr (strupr)
124 *
125 * PARAMETERS: src_string - The source string to convert
126 *
127 * RETURN: None
128 *
129 * DESCRIPTION: Convert string to uppercase
130 *
131 * NOTE: This is not a POSIX function, so it appears here, not in utclib.c
132 *
133 ******************************************************************************/
134
135void acpi_ut_strupr(char *src_string)
136{
137 char *string;
138
139 ACPI_FUNCTION_ENTRY();
140
141 if (!src_string) {
142 return;
143 }
144
145 /* Walk entire string, uppercasing the letters */
146
147 for (string = src_string; *string; string++) {
148 *string = (char)toupper((int)*string);
149 }
150
151 return;
152}
153
154/*******************************************************************************
155 *
156 * FUNCTION: acpi_ut_strtoul64
157 *
158 * PARAMETERS: string - Null terminated string
159 * base - Radix of the string: 16 or ACPI_ANY_BASE;
160 * ACPI_ANY_BASE means 'in behalf of to_integer'
161 * ret_integer - Where the converted integer is returned
162 *
163 * RETURN: Status and Converted value
164 *
165 * DESCRIPTION: Convert a string into an unsigned value. Performs either a
166 * 32-bit or 64-bit conversion, depending on the current mode
167 * of the interpreter.
168 * NOTE: Does not support Octal strings, not needed.
169 *
170 ******************************************************************************/
171
172acpi_status acpi_ut_strtoul64(char *string, u32 base, u64 *ret_integer)
173{
174 u32 this_digit = 0;
175 u64 return_value = 0;
176 u64 quotient;
177 u64 dividend;
178 u32 to_integer_op = (base == ACPI_ANY_BASE);
179 u32 mode32 = (acpi_gbl_integer_byte_width == 4);
180 u8 valid_digits = 0;
181 u8 sign_of0x = 0;
182 u8 term = 0;
183
184 ACPI_FUNCTION_TRACE_STR(ut_stroul64, string);
185
186 switch (base) {
187 case ACPI_ANY_BASE:
188 case 16:
189
190 break;
191
192 default:
193
194 /* Invalid Base */
195
196 return_ACPI_STATUS(AE_BAD_PARAMETER);
197 }
198
199 if (!string) {
200 goto error_exit;
201 }
202
203 /* Skip over any white space in the buffer */
204
205 while ((*string) && (isspace((int)*string) || *string == '\t')) {
206 string++;
207 }
208
209 if (to_integer_op) {
210 /*
211 * Base equal to ACPI_ANY_BASE means 'ToInteger operation case'.
212 * We need to determine if it is decimal or hexadecimal.
213 */
214 if ((*string == '0') && (tolower((int)*(string + 1)) == 'x')) {
215 sign_of0x = 1;
216 base = 16;
217
218 /* Skip over the leading '0x' */
219 string += 2;
220 } else {
221 base = 10;
222 }
223 }
224
225 /* Any string left? Check that '0x' is not followed by white space. */
226
227 if (!(*string) || isspace((int)*string) || *string == '\t') {
228 if (to_integer_op) {
229 goto error_exit;
230 } else {
231 goto all_done;
232 }
233 }
234
235 /*
236 * Perform a 32-bit or 64-bit conversion, depending upon the current
237 * execution mode of the interpreter
238 */
239 dividend = (mode32) ? ACPI_UINT32_MAX : ACPI_UINT64_MAX;
240
241 /* Main loop: convert the string to a 32- or 64-bit integer */
242
243 while (*string) {
244 if (isdigit((int)*string)) {
245
246 /* Convert ASCII 0-9 to Decimal value */
247
248 this_digit = ((u8)*string) - '0';
249 } else if (base == 10) {
250
251 /* Digit is out of range; possible in to_integer case only */
252
253 term = 1;
254 } else {
255 this_digit = (u8)toupper((int)*string);
256 if (isxdigit((int)this_digit)) {
257
258 /* Convert ASCII Hex char to value */
259
260 this_digit = this_digit - 'A' + 10;
261 } else {
262 term = 1;
263 }
264 }
265
266 if (term) {
267 if (to_integer_op) {
268 goto error_exit;
269 } else {
270 break;
271 }
272 } else if ((valid_digits == 0) && (this_digit == 0)
273 && !sign_of0x) {
274
275 /* Skip zeros */
276 string++;
277 continue;
278 }
279
280 valid_digits++;
281
282 if (sign_of0x
283 && ((valid_digits > 16)
284 || ((valid_digits > 8) && mode32))) {
285 /*
286 * This is to_integer operation case.
287 * No any restrictions for string-to-integer conversion,
288 * see ACPI spec.
289 */
290 goto error_exit;
291 }
292
293 /* Divide the digit into the correct position */
294
295 (void)acpi_ut_short_divide((dividend - (u64)this_digit),
296 base, &quotient, NULL);
297
298 if (return_value > quotient) {
299 if (to_integer_op) {
300 goto error_exit;
301 } else {
302 break;
303 }
304 }
305
306 return_value *= base;
307 return_value += this_digit;
308 string++;
309 }
310
311 /* All done, normal exit */
312
313all_done:
314
315 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Converted value: %8.8X%8.8X\n",
316 ACPI_FORMAT_UINT64(return_value)));
317
318 *ret_integer = return_value;
319 return_ACPI_STATUS(AE_OK);
320
321error_exit:
322 /* Base was set/validated above */
323
324 if (base == 10) {
325 return_ACPI_STATUS(AE_BAD_DECIMAL_CONSTANT);
326 } else {
327 return_ACPI_STATUS(AE_BAD_HEX_CONSTANT);
328 }
329}
330
331/******************************************************************************* 51/*******************************************************************************
332 * 52 *
333 * FUNCTION: acpi_ut_print_string 53 * FUNCTION: acpi_ut_print_string
@@ -342,7 +62,6 @@ error_exit:
342 * sequences. 62 * sequences.
343 * 63 *
344 ******************************************************************************/ 64 ******************************************************************************/
345
346void acpi_ut_print_string(char *string, u16 max_length) 65void acpi_ut_print_string(char *string, u16 max_length)
347{ 66{
348 u32 i; 67 u32 i;
@@ -584,64 +303,3 @@ void ut_convert_backslashes(char *pathname)
584 } 303 }
585} 304}
586#endif 305#endif
587
588#if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION)
589/*******************************************************************************
590 *
591 * FUNCTION: acpi_ut_safe_strcpy, acpi_ut_safe_strcat, acpi_ut_safe_strncat
592 *
593 * PARAMETERS: Adds a "DestSize" parameter to each of the standard string
594 * functions. This is the size of the Destination buffer.
595 *
596 * RETURN: TRUE if the operation would overflow the destination buffer.
597 *
598 * DESCRIPTION: Safe versions of standard Clib string functions. Ensure that
599 * the result of the operation will not overflow the output string
600 * buffer.
601 *
602 * NOTE: These functions are typically only helpful for processing
603 * user input and command lines. For most ACPICA code, the
604 * required buffer length is precisely calculated before buffer
605 * allocation, so the use of these functions is unnecessary.
606 *
607 ******************************************************************************/
608
609u8 acpi_ut_safe_strcpy(char *dest, acpi_size dest_size, char *source)
610{
611
612 if (strlen(source) >= dest_size) {
613 return (TRUE);
614 }
615
616 strcpy(dest, source);
617 return (FALSE);
618}
619
620u8 acpi_ut_safe_strcat(char *dest, acpi_size dest_size, char *source)
621{
622
623 if ((strlen(dest) + strlen(source)) >= dest_size) {
624 return (TRUE);
625 }
626
627 strcat(dest, source);
628 return (FALSE);
629}
630
631u8
632acpi_ut_safe_strncat(char *dest,
633 acpi_size dest_size,
634 char *source, acpi_size max_transfer_length)
635{
636 acpi_size actual_transfer_length;
637
638 actual_transfer_length = ACPI_MIN(max_transfer_length, strlen(source));
639
640 if ((strlen(dest) + actual_transfer_length) >= dest_size) {
641 return (TRUE);
642 }
643
644 strncat(dest, source, max_transfer_length);
645 return (FALSE);
646}
647#endif