From 14757da55950d2227c4960f94db2e9ceca71a58f Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 12 Dec 2023 13:45:28 -0700 Subject: [PATCH] revert spurious whitespace changes Signed-off-by: Joel Dice --- .../cloudlibc/src/libc/sys/ioctl/ioctl.c | 138 +++++++++--------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c b/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c index 3f58afe02..1ffddf0d3 100644 --- a/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c +++ b/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c @@ -2,17 +2,17 @@ // // SPDX-License-Identifier: BSD-2-Clause -#include -#include #include + #include +#include +#include #ifdef __wasilibc_use_preview2 #include #endif -int ioctl(int fildes, int request, ...) -{ +int ioctl(int fildes, int request, ...) { #ifdef __wasilibc_use_preview2 descriptor_table_entry_t* entry; if (descriptor_table_get_ref(fildes, &entry)) { @@ -44,80 +44,80 @@ int ioctl(int fildes, int request, ...) } #endif // __wasilibc_use_preview2 - switch (request) { + switch (request) { case FIONREAD: { - // Poll the file descriptor to determine how many bytes can be read. - __wasi_subscription_t subscriptions[2] = { - { - .u.tag = __WASI_EVENTTYPE_FD_READ, - .u.u.fd_read.file_descriptor = fildes, - }, - { - .u.tag = __WASI_EVENTTYPE_CLOCK, - .u.u.clock.id = __WASI_CLOCKID_MONOTONIC, - }, - }; - __wasi_event_t events[__arraycount(subscriptions)]; - size_t nevents; - __wasi_errno_t error = __wasi_poll_oneoff( - subscriptions, events, __arraycount(subscriptions), &nevents); - if (error != 0) { - errno = error; - return -1; - } + // Poll the file descriptor to determine how many bytes can be read. + __wasi_subscription_t subscriptions[2] = { + { + .u.tag = __WASI_EVENTTYPE_FD_READ, + .u.u.fd_read.file_descriptor = fildes, + }, + { + .u.tag = __WASI_EVENTTYPE_CLOCK, + .u.u.clock.id = __WASI_CLOCKID_MONOTONIC, + }, + }; + __wasi_event_t events[__arraycount(subscriptions)]; + size_t nevents; + __wasi_errno_t error = __wasi_poll_oneoff( + subscriptions, events, __arraycount(subscriptions), &nevents); + if (error != 0) { + errno = error; + return -1; + } - // Location where result should be written. - va_list ap; - va_start(ap, request); - int* result = va_arg(ap, int*); - va_end(ap); + // Location where result should be written. + va_list ap; + va_start(ap, request); + int *result = va_arg(ap, int *); + va_end(ap); - // Extract number of bytes for reading from poll results. - for (size_t i = 0; i < nevents; ++i) { - __wasi_event_t* event = &events[i]; - if (event->error != 0) { - errno = event->error; - return -1; - } - if (event->type == __WASI_EVENTTYPE_FD_READ) { - *result = event->fd_readwrite.nbytes; - return 0; - } + // Extract number of bytes for reading from poll results. + for (size_t i = 0; i < nevents; ++i) { + __wasi_event_t *event = &events[i]; + if (event->error != 0) { + errno = event->error; + return -1; + } + if (event->type == __WASI_EVENTTYPE_FD_READ) { + *result = event->fd_readwrite.nbytes; + return 0; } + } - // No data available for reading. - *result = 0; - return 0; + // No data available for reading. + *result = 0; + return 0; } case FIONBIO: { - // Obtain the current file descriptor flags. - __wasi_fdstat_t fds; - __wasi_errno_t error = __wasi_fd_fdstat_get(fildes, &fds); - if (error != 0) { - errno = error; - return -1; - } + // Obtain the current file descriptor flags. + __wasi_fdstat_t fds; + __wasi_errno_t error = __wasi_fd_fdstat_get(fildes, &fds); + if (error != 0) { + errno = error; + return -1; + } - // Toggle the non-blocking flag based on the argument. - va_list ap; - va_start(ap, request); - if (*va_arg(ap, const int*) != 0) - fds.fs_flags |= __WASI_FDFLAGS_NONBLOCK; - else - fds.fs_flags &= ~__WASI_FDFLAGS_NONBLOCK; - va_end(ap); + // Toggle the non-blocking flag based on the argument. + va_list ap; + va_start(ap, request); + if (*va_arg(ap, const int *) != 0) + fds.fs_flags |= __WASI_FDFLAGS_NONBLOCK; + else + fds.fs_flags &= ~__WASI_FDFLAGS_NONBLOCK; + va_end(ap); - // Update the file descriptor flags. - error = __wasi_fd_fdstat_set_flags(fildes, fds.fs_flags); - if (error != 0) { - errno = error; - return -1; - } - return 0; - } - default: - // Invalid request. - errno = EINVAL; + // Update the file descriptor flags. + error = __wasi_fd_fdstat_set_flags(fildes, fds.fs_flags); + if (error != 0) { + errno = error; return -1; + } + return 0; } + default: + // Invalid request. + errno = EINVAL; + return -1; + } }