static char *acpi_ut_put_number(char *string, u64 number, u8 base, u8 upper);
+/* Module globals */
+
+static const char acpi_gbl_lower_hex_digits[] = "0123456789abcdef";
+static const char acpi_gbl_upper_hex_digits[] = "0123456789ABCDEF";
+
/*******************************************************************************
*
* FUNCTION: acpi_ut_bound_string_length
* PARAMETERS: string - String with boundary
* count - Boundary of the string
*
- * RETURN: Length of the string.
+ * RETURN: Length of the string. Less than or equal to Count.
*
* DESCRIPTION: Calculate the length of a string with boundary.
*
if (string < end) {
*string = c;
}
- ++string;
+ ++string;
return (string);
}
static char *acpi_ut_put_number(char *string, u64 number, u8 base, u8 upper)
{
- const char lower_digits[] = "0123456789abcdef";
- const char upper_digits[] = "0123456789ABCDEF";
const char *digits;
u64 digit_index;
char *pos;
pos = string;
- digits = upper ? upper_digits : lower_digits;
+ digits = upper ? acpi_gbl_upper_hex_digits : acpi_gbl_lower_hex_digits;
if (number == 0) {
*(pos++) = '0';
*(pos++) = digits[digit_index];
}
}
- /* *(Pos++) = '0'; */
+ /* *(Pos++) = '0'; */
return (pos);
}
number *= 10;
number += *(string++) - '0';
}
- *number_ptr = number;
+ *number_ptr = number;
return (string);
}
while (pos1 != ascii_string) {
*(pos2++) = *(--pos1);
}
- *pos2 = 0;
+ *pos2 = 0;
return (string);
}
s32 i;
char reversed_string[66];
- /* Perform sanity checks */
+ /* Parameter validation */
if (base < 2 || base > 16) {
- return NULL;
+ return (NULL);
}
+
if (type & ACPI_FORMAT_LEFT) {
type &= ~ACPI_FORMAT_ZERO;
}
if (i > precision) {
precision = i;
}
+
width -= precision;
/* Output the string */
string = acpi_ut_bound_string_output(string, end, zero);
}
}
+
while (i <= --precision) {
string = acpi_ut_bound_string_output(string, end, '0');
}
* format - Standard printf format
* args - Argument list
*
- * RETURN: Size of successfully output bytes
+ * RETURN: Number of bytes actually written.
*
* DESCRIPTION: Formatted output to a string using argument list pointer.
*
if (*format == 'h' || *format == 'l' || *format == 'L') {
qualifier = *format;
++format;
+
if (qualifier == 'l' && *format == 'l') {
qualifier = 'L';
++format;
' ');
}
}
+
c = (char)va_arg(args, int);
pos = acpi_ut_bound_string_output(pos, end, c);
+
while (--width > 0) {
pos =
acpi_ut_bound_string_output(pos, end, ' ');
width = 2 * sizeof(void *);
type |= ACPI_FORMAT_ZERO;
}
+
p = va_arg(args, void *);
pos = acpi_ut_format_number(pos, end,
- ACPI_TO_INTEGER(p),
- 16, width, precision, type);
+ ACPI_TO_INTEGER(p), 16,
+ width, precision, type);
continue;
default:
number = (signed int)number;
}
}
+
pos = acpi_ut_format_number(pos, end, number, base,
width, precision, type);
}
* size - Boundary of the string
* Format, ... - Standard printf format
*
- * RETURN: Size of successfully output bytes
+ * RETURN: Number of bytes actually written.
*
* DESCRIPTION: Formatted output to a string.
*
* format - Standard printf format
* args - Argument list
*
- * RETURN: Size of successfully output bytes
+ * RETURN: Number of bytes actually written.
*
* DESCRIPTION: Formatted output to a file using argument list pointer.
*
flags = acpi_os_acquire_lock(acpi_gbl_print_lock);
length = acpi_ut_vsnprintf(acpi_gbl_print_buffer,
sizeof(acpi_gbl_print_buffer), format, args);
+
(void)acpi_os_write_file(file, acpi_gbl_print_buffer, length, 1);
acpi_os_release_lock(acpi_gbl_print_lock, flags);
* PARAMETERS: file - File descriptor
* Format, ... - Standard printf format
*
- * RETURN: Size of successfully output bytes
+ * RETURN: Number of bytes actually written.
*
* DESCRIPTION: Formatted output to a file.
*
/******************************************************************************
*
- * Module Name: oslibcfs - C library OSL for file IO
+ * Module Name: oslibcfs - C library OSL for file I/O
*
*****************************************************************************/
ACPI_FILE acpi_os_open_file(const char *path, u8 modes)
{
ACPI_FILE file;
- char modes_str[4];
u32 i = 0;
+ char modes_str[4];
if (modes & ACPI_FILE_READING) {
modes_str[i++] = 'r';
if (modes & ACPI_FILE_BINARY) {
modes_str[i++] = 'b';
}
+
modes_str[i++] = '\0';
file = fopen(path, modes_str);
*
* FUNCTION: acpi_os_close_file
*
- * PARAMETERS: file - File descriptor
+ * PARAMETERS: file - An open file descriptor
*
* RETURN: None.
*
- * DESCRIPTION: Close a file.
+ * DESCRIPTION: Close a file opened via acpi_os_open_file.
*
******************************************************************************/
*
* FUNCTION: acpi_os_read_file
*
- * PARAMETERS: file - File descriptor
+ * PARAMETERS: file - An open file descriptor
* buffer - Data buffer
* size - Data block size
* count - Number of data blocks
*
- * RETURN: Size of successfully read buffer.
+ * RETURN: Number of bytes actually read.
*
- * DESCRIPTION: Read a file.
+ * DESCRIPTION: Read from a file.
*
******************************************************************************/
*
* FUNCTION: acpi_os_write_file
*
- * PARAMETERS: file - File descriptor
+ * PARAMETERS: file - An open file descriptor
* buffer - Data buffer
* size - Data block size
* count - Number of data blocks
*
- * RETURN: Size of successfully written buffer.
+ * RETURN: Number of bytes actually written.
*
- * DESCRIPTION: Write a file.
+ * DESCRIPTION: Write to a file.
*
******************************************************************************/
*
* FUNCTION: acpi_os_get_file_offset
*
- * PARAMETERS: file - File descriptor
+ * PARAMETERS: file - An open file descriptor
*
- * RETURN: Size of current position.
+ * RETURN: Current file pointer position.
*
* DESCRIPTION: Get current file offset.
*
long offset;
offset = ftell(file);
-
return (offset);
}
*
* FUNCTION: acpi_os_set_file_offset
*
- * PARAMETERS: file - File descriptor
- * offset - File offset
+ * PARAMETERS: file - An open file descriptor
+ * offset - New file offset
* from - From begin/end of file
*
* RETURN: Status