From 9fe5e6bf0ccaccec9c5ea2c3a2cea86dbd9c78dc Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Tue, 9 May 2023 00:31:36 +0300 Subject: Style tweaks Message-Id: <20230508213136.608575-42-bugaevc@gmail.com> --- console-client/trans.c | 80 +++++++++++++++++++++---------------------- console-client/trans.h | 10 +++--- fatfs/dir.c | 12 +++---- libpager/pager-memcpy.c | 8 ++--- libports/manage-multithread.c | 6 ++-- libps/proclist.c | 2 +- pflocal/pf.c | 4 +-- pflocal/socket.c | 2 +- procfs/rootdir.c | 4 +-- tmpfs/tmpfs.c | 2 +- utils/ps.c | 12 +++---- 11 files changed, 70 insertions(+), 72 deletions(-) diff --git a/console-client/trans.c b/console-client/trans.c index 78716f34..e43dec66 100644 --- a/console-client/trans.c +++ b/console-client/trans.c @@ -3,7 +3,7 @@ Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. Written by Marco Gerards. - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at @@ -75,17 +75,17 @@ console_demuxer (mach_msg_header_t *inp, netfs_protid_class); if (!user) return ret; - + /* Don't do anything for the root node. */ if (user->po->np == netfs_root_node) { ports_port_deref (user); return 0; - } - + } + if (!ret && user->po->np->nn->node && user->po->np->nn->node->demuxer) ret = user->po->np->nn->node->demuxer (inp, outp); - + ports_port_deref (user); return ret; } @@ -187,10 +187,10 @@ netfs_attempt_utimes (struct iouser *cred, struct node *np, { if (mtime) np->nn_stat.st_mtim = *mtime; - + if (atime) np->nn_stat.st_atim = *atime; - + fshelp_touch (&np->nn_stat, flags, console_maptime); } return err; @@ -248,7 +248,7 @@ netfs_attempt_lookup (struct iouser *user, struct node *dir, { error_t err; consnode_t cn; - + *node = 0; err = fshelp_access (&dir->nn_stat, S_IEXEC, user); if (err) @@ -268,7 +268,7 @@ netfs_attempt_lookup (struct iouser *user, struct node *dir, err = EAGAIN; goto out; } - + for (cn = node_list; cn; cn = cn->next) if (!strcmp (name, cn->name)) { @@ -293,9 +293,9 @@ netfs_attempt_lookup (struct iouser *user, struct node *dir, err = ENOMEM; goto out; } - + *node = netfs_make_node (nn); - + nn->node = cn; (*node)->nn_stat = netfs_root_node->nn_stat; (*node)->nn_stat.st_mode = (netfs_root_node->nn_stat.st_mode & ~S_IFMT & ~S_ITRANS); @@ -311,21 +311,21 @@ netfs_attempt_lookup (struct iouser *user, struct node *dir, else { *node = cn->node; - + netfs_nref (*node); goto out; } } - + err = ENOENT; - + out: pthread_mutex_unlock (&dir->lock); if (err) *node = 0; else pthread_mutex_lock (&(*node)->lock); - + if (!err && *node != dir && (*node)->nn->node->open) (*node)->nn->node->open (); @@ -351,12 +351,12 @@ io_select_common (struct protid *user, mach_port_t reply, struct timespec *tsp, int *type) { struct node *np; - + if (!user) return EOPNOTSUPP; - + np = user->po->np; - + if (np->nn->node && np->nn->node->select) return np->nn->node->select (user, reply, replytype, tsp, type); return EOPNOTSUPP; @@ -581,11 +581,11 @@ netfs_S_io_read (struct protid *user, vm_size_t amount) { struct node *np; - + if (!user) return EOPNOTSUPP; np = user->po->np; - + if (np->nn->node && np->nn->node->read) return np->nn->node->read (user, data, datalen, offset, amount); return EOPNOTSUPP; @@ -600,10 +600,10 @@ netfs_S_io_write (struct protid *user, vm_size_t *amount) { struct node *np; - + if (!user) return EOPNOTSUPP; - + np = user->po->np; if (np->nn->node && np->nn->node->write) return np->nn->node->write (user, data, datalen, offset, amount); @@ -630,7 +630,6 @@ netfs_report_access (struct iouser *cred, struct node *np, /* Node NP has no more references; free all its associated storage. */ void netfs_node_norefs (struct node *np) - { if (np->nn->node) { @@ -673,7 +672,6 @@ netfs_get_dirents (struct iouser *cred, struct node *dir, size_t size = 0; /* Total size of our return block. */ consnode_t cn = node_list; consnode_t first_node; - /* Add the length of a directory entry for NAME to SIZE and return true, unless it would overflow MAX_DATA_LEN or NUM_ENTRIES, in which case @@ -760,7 +758,7 @@ netfs_get_dirents (struct iouser *cred, struct node *dir, *data_len = size; *data_entries = count; - + count = 0; /* Add `.' and `..' entries. */ @@ -768,13 +766,13 @@ netfs_get_dirents (struct iouser *cred, struct node *dir, add_dir_entry (".", 2, DT_DIR); if (first_entry <= 1) add_dir_entry ("..", 2, DT_DIR); - + /* Fill in the real directory entries. */ for (cn = first_node; cn; cn = cn->next) if (!add_dir_entry (cn->name, cn->id, cn->readlink ? DT_LNK : DT_CHR)) break; } - + fshelp_touch (&dir->nn_stat, TOUCH_ATIME, console_maptime); return err; } @@ -786,7 +784,7 @@ console_client_translator (void *unused) { error_t err; - do + do { ports_manage_port_operations_multithread (netfs_port_bucket, console_demuxer, @@ -810,7 +808,7 @@ console_create_consnode (const char *name, consnode_t *cn) *cn = malloc (sizeof (struct consnode)); if (!*cn) return ENOMEM; - + (*cn)->name = strdup (name); if (!(*cn)->name) { @@ -853,16 +851,16 @@ console_unregister_consnode (consnode_t cn) { if (!cn) return; - + if (node_list == cn) node_list = cn->next; else { consnode_t prev = node_list; - + for (prev = node_list; prev->next != cn; prev = prev->next) ; - + prev->next = cn->next; } } @@ -877,32 +875,32 @@ console_setup_node (char *path) struct port_info *newpi; mach_port_t right; pthread_t thread; - + node = file_name_lookup (path, O_CREAT|O_NOTRANS, 0664); if (node == MACH_PORT_NULL) return errno; netfs_init (); - + /* Create the root node (some attributes initialized below). */ netfs_root_node = netfs_make_node (0); if (! netfs_root_node) error (1, ENOMEM, "Cannot create root node"); - + err = maptime_map (0, 0, &console_maptime); if (err) error (1, err, "Cannot map time"); - + err = ports_create_port (netfs_control_class, netfs_port_bucket, sizeof (struct port_info), &newpi); right = ports_get_send_right (newpi); err = file_set_translator (node, 0, FS_TRANS_EXCL | FS_TRANS_SET, 0, 0, 0, - right, MACH_MSG_TYPE_COPY_SEND); + right, MACH_MSG_TYPE_COPY_SEND); mach_port_deallocate (mach_task_self (), right); - + err = io_stat (node, &ul_stat); if (err) error (1, err, "Cannot stat underlying node"); - + netfs_root_node->nn_stat.st_ino = 2; netfs_root_node->nn_stat.st_uid = ul_stat.st_uid; netfs_root_node->nn_stat.st_gid = ul_stat.st_gid; @@ -926,10 +924,10 @@ console_setup_node (char *path) if (ul_stat.st_mode & S_IROTH) netfs_root_node->nn_stat.st_mode |= S_IXOTH; } - + fshelp_touch (&netfs_root_node->nn_stat, TOUCH_ATIME|TOUCH_MTIME|TOUCH_CTIME, console_maptime); - + err = pthread_create (&thread, NULL, console_client_translator, NULL); if (!err) pthread_detach (thread); diff --git a/console-client/trans.h b/console-client/trans.h index 6089b987..27ccc0ab 100644 --- a/console-client/trans.h +++ b/console-client/trans.h @@ -25,10 +25,10 @@ struct consnode /* The id of the node. */ int id; - + /* Cached if the node is already opened. */ struct node *node; - + /* Read data from a node. This is exactly the same as io_read does. */ error_t (*read) (struct protid *user, char **data, @@ -48,10 +48,10 @@ struct consnode /* Called when the node is opened. */ void (*open) (void); - + /* Called when the node is closed. */ void (*close) (void); - + /* The demuxer used for this node. */ int (*demuxer) (mach_msg_header_t *inp, mach_msg_header_t *outp); @@ -60,7 +60,7 @@ struct consnode /* Called when the symlink is written */ error_t (*mksymlink) (struct iouser *cred, struct node *np, const char *name); - + struct consnode *next; }; diff --git a/fatfs/dir.c b/fatfs/dir.c index 71974642..79852a77 100644 --- a/fatfs/dir.c +++ b/fatfs/dir.c @@ -652,19 +652,19 @@ diskfs_direnter_hard (struct node *dp, const char *name, struct node *np, write_word (new->first_cluster_low, np->dn->start_cluster & 0xffff); write_word (new->first_cluster_high, np->dn->start_cluster >> 16); write_dword (new->file_size, np->dn_stat.st_size); - + if (!(name[0] == '.' && (name[1] == '\0' || (name[1] == '.' && name[2] =='\0')))) { vi_key_t entry_key; - + entry_key.dir_inode = dp->cache_id; entry_key.dir_offset = (uintptr_t) ds->entry - (uintptr_t) ds->mapbuf; - + /* Set the key for this inode now because it wasn't know when the inode was initialized. */ vi_change (vi_lookup (np->cache_id), entry_key); - + if (np->dn_stat.st_mode & S_IFDIR) new->attribute = FAT_DIR_ATTR_DIR; } @@ -724,7 +724,7 @@ diskfs_dirrewrite_hard (struct node *dp, struct node *np, struct dirstat *ds) struct node *oldnp; ino_t inode; inode_t vinode; - + /* We need the inode and vinode of the old node. */ entry_key.dir_inode = dp->cache_id; entry_key.dir_offset = (uintptr_t) ds->entry - (uintptr_t) ds->mapbuf; @@ -836,7 +836,7 @@ diskfs_get_directs (struct node *dp, vm_size_t bufsiz, int *amt) { - volatile vm_size_t allocsize; + vm_size_t allocsize; struct dirrect *ep; struct dirent *userp; int i; diff --git a/libpager/pager-memcpy.c b/libpager/pager-memcpy.c index 5a5aac2a..caaf6f2a 100644 --- a/libpager/pager-memcpy.c +++ b/libpager/pager-memcpy.c @@ -63,7 +63,7 @@ pager_memcpy (struct pager *pager, memory_object_t memobj, assert_backtrace (window_size >= VMCOPY_BETTER_THAN_MEMCPY); assert_backtrace ((window_size & (vm_page_size - 1)) == 0); - + window = 0; err = vm_map (mach_task_self (), &window, window_size, 0, 1, memobj, offset, 0, prot, prot, VM_INHERIT_NONE); @@ -127,7 +127,7 @@ pager_memcpy (struct pager *pager, memory_object_t memobj, memcpy (other, (const void *) window + pageoff, copy_count); else memcpy ((void *) window + pageoff, other, copy_count); - + vm_deallocate (mach_task_self (), window, window_size); assert_backtrace (n >= copy_count); @@ -139,7 +139,7 @@ pager_memcpy (struct pager *pager, memory_object_t memobj, n -= copy_count; } while (to_copy > 0); - + return 0; } @@ -156,7 +156,7 @@ pager_memcpy (struct pager *pager, memory_object_t memobj, - ((vm_address_t) other & (vm_page_size - 1))); if (err) return err; - + assert_backtrace (n >= VMCOPY_BETTER_THAN_MEMCPY); err = do_vm_copy (); diff --git a/libports/manage-multithread.c b/libports/manage-multithread.c index 0f8af8ea..9c036911 100644 --- a/libports/manage-multithread.c +++ b/libports/manage-multithread.c @@ -160,10 +160,10 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket, perror ("pthread_create"); } } - + /* Fill in default response. */ - outp->Head.msgh_bits - = MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(inp->msgh_bits), 0); + outp->Head.msgh_bits + = MACH_MSGH_BITS (MACH_MSGH_BITS_REMOTE (inp->msgh_bits), 0); outp->Head.msgh_size = sizeof *outp; outp->Head.msgh_remote_port = inp->msgh_remote_port; outp->Head.msgh_local_port = MACH_PORT_NULL; diff --git a/libps/proclist.c b/libps/proclist.c index 3d84c49b..e1ce4c16 100644 --- a/libps/proclist.c +++ b/libps/proclist.c @@ -282,7 +282,7 @@ proc_stat_list_add_fn_pids (struct proc_stat_list *pp, *num_procs = num_pids; if (pids != pid_array) - VMFREE(pids, sizeof (pid_t) * num_pids); + VMFREE (pids, sizeof (pid_t) * num_pids); return err; } diff --git a/pflocal/pf.c b/pflocal/pf.c index 45b132eb..482f3b93 100644 --- a/pflocal/pf.c +++ b/pflocal/pf.c @@ -135,7 +135,7 @@ S_socket_whatis_address (struct addr *addr, mach_msg_type_number_t *sockaddr_len) { socklen_t addr_len = (offsetof (struct sockaddr, sa_data) + 1); - + if (! addr) return EOPNOTSUPP; @@ -146,6 +146,6 @@ S_socket_whatis_address (struct addr *addr, ((struct sockaddr *) *sockaddr)->sa_family = *sockaddr_type; ((struct sockaddr *) *sockaddr)->sa_data[0] = 0; *sockaddr_len = addr_len; - + return 0; } diff --git a/pflocal/socket.c b/pflocal/socket.c index 625980b9..0e0f8d78 100644 --- a/pflocal/socket.c +++ b/pflocal/socket.c @@ -342,7 +342,7 @@ S_socket_send (struct sock_user *user, struct addr *dest_addr, int flags, else /* No address, must be a connected socket... */ err = sock_acquire_write_pipe (sock, &pipe); - + if (!err) { noblock = (user->sock->flags & PFLOCAL_SOCK_NONBLOCK) diff --git a/procfs/rootdir.c b/procfs/rootdir.c index 1c7181b1..908cfe6c 100644 --- a/procfs/rootdir.c +++ b/procfs/rootdir.c @@ -683,8 +683,8 @@ rootdir_gc_swaps (void *hook, char **contents, ssize_t *contents_len) name = argz_next (names, names_len, name); } - vm_deallocate (mach_task_self(), (vm_offset_t) free, nfree * sizeof(*free)); - vm_deallocate (mach_task_self(), (vm_offset_t) size, nsize * sizeof(*size)); + vm_deallocate (mach_task_self(), (vm_offset_t) free, nfree * sizeof (*free)); + vm_deallocate (mach_task_self(), (vm_offset_t) size, nsize * sizeof (*size)); vm_deallocate (mach_task_self(), (vm_offset_t) names, names_len); out: diff --git a/tmpfs/tmpfs.c b/tmpfs/tmpfs.c index 195813c4..02d4bd8c 100644 --- a/tmpfs/tmpfs.c +++ b/tmpfs/tmpfs.c @@ -289,7 +289,7 @@ diskfs_append_args (char **argz, size_t *argz_len) return err; } -/* Handling of operations for the ports in diskfs_port_bucket, calling +/* Handling of operations for the ports in diskfs_port_bucket, calling * demuxer for each incoming message */ static void * diskfs_thread_function (void *demuxer) diff --git a/utils/ps.c b/utils/ps.c index 3c8c3c88..a852b92f 100644 --- a/utils/ps.c +++ b/utils/ps.c @@ -228,9 +228,9 @@ main(int argc, char *argv[]) argp_failure (state, 8, err, "%s: Can't add tty", tty_name); return err; } - int proc_stat_has_ctty(struct proc_stat *ps) + int proc_stat_has_ctty (struct proc_stat *ps) { - if (proc_stat_has(ps, PSTAT_TTY)) + if (proc_stat_has (ps, PSTAT_TTY)) /* Only match processes whose tty we can figure out. */ { struct ps_tty *tty = proc_stat_tty (ps); @@ -238,7 +238,7 @@ main(int argc, char *argv[]) { char *try = 0; const char *name = ps_tty_name (tty); - const char *short_name = ps_tty_short_name(tty); + const char *short_name = ps_tty_short_name (tty); while ((try = argz_next (tty_names, num_tty_names, try))) if ((name && strcmp (try, name) == 0) @@ -254,14 +254,14 @@ main(int argc, char *argv[]) { error_t err; struct ps_tty *tty; - mach_port_t cttyid = getcttyid(); + mach_port_t cttyid = getcttyid (); if (cttyid == MACH_PORT_NULL) - error(2, 0, "No controlling terminal"); + error (2, 0, "No controlling terminal"); err = ps_context_find_tty_by_cttyid (context, cttyid, &tty); if (err) - error(2, err, "Can't get controlling terminal"); + error (2, err, "Can't get controlling terminal"); return ps_tty_name (tty); } -- cgit v1.2.3