Re-format code to avoid overly long lines and declarations

This commit is contained in:
Nils O. Selåsdal
2015-04-04 23:29:27 +02:00
parent a55139aba6
commit c6318c079d
17 changed files with 94 additions and 46 deletions
+3 -3
View File
@@ -82,7 +82,7 @@ extern struct UCoreClock uc_time_clock;
*
*/
void uc_cached_clock_init(struct UCoreCachedClock *uclock,
struct UCoreClock *real_clock);
struct UCoreClock *real_clock);
/** Update the cached clock from the real_clock
*/
@@ -103,7 +103,7 @@ void uc_settable_clock_init(struct UCoreSettableClock *uclock);
* @param tv new timeval to set the clock to
**/
void uc_settable_clock_set_tv(struct UCoreSettableClock *uclock,
const struct timeval *tv);
const struct timeval *tv);
/**
* Set the new time this clock will return
@@ -114,7 +114,7 @@ void uc_settable_clock_set_tv(struct UCoreSettableClock *uclock,
* @param usecs microseconds portion of the clock to set.
**/
void uc_settable_clock_set(struct UCoreSettableClock *uclock,
time_t secs, suseconds_t usecs);
time_t secs, suseconds_t usecs);
#ifdef __cplusplus
}
+2 -1
View File
@@ -73,7 +73,8 @@ static inline size_t uc_htable_bucket(const struct UHTable *table, size_t hash)
* @param table table
* @param hash hash
*/
static inline struct UHNode *uc_htable_first_bucket(const struct UHTable *table, size_t hash)
static inline struct UHNode *uc_htable_first_bucket(const struct UHTable *table,
size_t hash)
{
size_t bucket = uc_htable_bucket(table, hash);
+13 -5
View File
@@ -171,7 +171,8 @@ const char *uc_ll_2_str(enum UC_LOG_LEVEL l);
* @return An opaque uc_log_destination that can be added as a destination to
* the ucore logging system
*/
struct UCLogDestination *uc_log_new_stderr(enum UC_LOG_LEVEL log_level, int log_location);
struct UCLogDestination *uc_log_new_stderr(enum UC_LOG_LEVEL log_level,
int log_location);
/* creates a new uc_log_destination for logging to syslog
*
@@ -184,7 +185,10 @@ struct UCLogDestination *uc_log_new_stderr(enum UC_LOG_LEVEL log_level, int log_
* @return An opaque uc_log_destination that can be added as a destination to
* the ucore logging system
*/
struct UCLogDestination *uc_log_new_syslog(const char *ident, int facility, enum UC_LOG_LEVEL log_level, int log_location);
struct UCLogDestination *uc_log_new_syslog(const char *ident,
int facility,
enum UC_LOG_LEVEL log_level,
int log_location);
/* creates a new uc_log_destination for printing on stderr.
*
@@ -195,7 +199,9 @@ struct UCLogDestination *uc_log_new_syslog(const char *ident, int facility, enum
* @param return An opaque uc_log_destination that can be added as a destination to
* the ucore logging system
*/
struct UCLogDestination *uc_log_new_file(const char *filename, enum UC_LOG_LEVEL log_level, int log_location);
struct UCLogDestination *uc_log_new_file(const char *filename,
enum UC_LOG_LEVEL log_level,
int log_location);
/** Add a uc_log_destination to the logging system.
*
@@ -216,7 +222,8 @@ void uc_log_remove_destination(struct UCLogDestination *dest);
* @param dest destination for which to set the log level
* @param level The new log level
*/
void uc_log_destination_set_loglevel(struct UCLogDestination *dest, enum UC_LOG_LEVEL level);
void uc_log_destination_set_loglevel(struct UCLogDestination *dest,
enum UC_LOG_LEVEL level);
/** Change whether to log the location (file/line no.) of logging
* output on a destination,
@@ -224,7 +231,8 @@ void uc_log_destination_set_loglevel(struct UCLogDestination *dest, enum UC_LOG_
* @param dest log destination to change
* @param log_location 1=log the locaton, 0=don't log the location
*/
void uc_log_destination_set_log_location(struct UCLogDestination *dest, int log_location);
void uc_log_destination_set_log_location(struct UCLogDestination *dest,
int log_location);
/** Sets the log rotation settings.
* Does nothing if the destination is not a UC_LDEST_FILE, or the policy is invalid.
+2 -1
View File
@@ -127,7 +127,8 @@ struct MBuf *uc_mbuf_copy_data(struct MBuf *mbuf);
* @param headroom the headroom in the buffer
* @param flags The appropriate UC_MBUF_FLAGS
*/
void uc_mbuf_init(struct MBuf *mbuf, uint8_t *restrict buf, uint32_t len, uint32_t headroom, uint32_t flags);
void uc_mbuf_init(struct MBuf *mbuf, uint8_t *restrict buf, uint32_t len,
uint32_t headroom, uint32_t flags);
/** Zero out all the data in this mbuf, including the headroom
*
+1 -2
View File
@@ -54,8 +54,7 @@ typedef enum {
* @param filename the filename to use to keep track of the state
* @param flags one of UC_RC_FL_XX
*/
UCRCResult uc_restart_counter_init(
struct UCRestartCounter *counter,
UCRCResult uc_restart_counter_init(struct UCRestartCounter *counter,
const char *filename,
unsigned int flags);
+9 -3
View File
@@ -36,7 +36,9 @@ uint8_t* uc_hex_decode(const char *restrict in, size_t maxlen,uint8_t *restrict
/** As uc_hex_encode , but inserts the @delim string between each converted
* byte (each 2 hex chars)
*/
char* uc_hex_encode_delim(const uint8_t *restrict in, size_t inlen, char *restrict out, int outlen, const char *restrict delim);
char* uc_hex_encode_delim(const uint8_t *restrict in, size_t inlen,
char *restrict out, int outlen,
const char *restrict delim);
/**
* Convert the string to lowercase, calls tolower() on each char.
@@ -67,7 +69,9 @@ void uc_str_toupper(char *s);
* if the number of ASCII digits is odd. This would usually be 0x0 or 0xf.
* @return the number of bytes written to bcdout
*/
size_t uc_ascii2bcd(const char *restrict ascii, unsigned char *restrict bcdout, unsigned char filler);
size_t uc_ascii2bcd(const char *restrict ascii,
unsigned char *restrict bcdout,
unsigned char filler);
/** Convert the BCD digits to ascii.
* The resulting ascii string is 0 terminated.
@@ -77,7 +81,9 @@ size_t uc_ascii2bcd(const char *restrict ascii, unsigned char *restrict bcdout,
* @param asciiout buffer to place ASCII in, must be UC_ASCII_LEN(bcdlen)+1 big
* @return the number of characters written to bcdout (this will always be UC_ASCII_LEN(bcdlen)
*/
size_t uc_bcd2ascii(const unsigned char *restrict bcd, size_t bcdlen, char *restrict asciiout);
size_t uc_bcd2ascii(const unsigned char *restrict bcd,
size_t bcdlen,
char *restrict asciiout);
/** uc_sprintb for converting the values into ascii bit representation
* e.g. 0x3 -> "00000011". The result must be able to hold the max number
+19 -7
View File
@@ -174,13 +174,16 @@ int uc_thread_queue_init(struct uc_threadqueue *queue, unsigned int max_elements
* @return 0 on succes ENOMEM if out of memory EINVAL if queue is NULL, ETIMEDOUT if timeout occured or other
* errno values if pthread functions failed.
*/
int uc_thread_queue_tryadd(struct uc_threadqueue *queue, const struct timespec *timeout, struct uc_threadmsg *msg);
int uc_thread_queue_tryadd(struct uc_threadqueue *queue,
const struct timespec *timeout,
struct uc_threadmsg *msg);
/**
* Like uc_thread_queue_add but will wait indefintly.
* @see uc_thread_queue_add
*/
static inline int uc_thread_queue_add(struct uc_threadqueue *queue, struct uc_threadmsg *msg)
static inline int uc_thread_queue_add(struct uc_threadqueue *queue,
struct uc_threadmsg *msg)
{
return uc_thread_queue_tryadd(queue, NULL, msg);
}
@@ -207,14 +210,17 @@ static inline int uc_thread_queue_add(struct uc_threadqueue *queue, struct uc_th
*
* @return 0 on success EINVAL if queue is NULL ETIMEDOUT if timeout occurs
*/
int uc_thread_queue_tryget(struct uc_threadqueue *queue, const struct timespec *timeout, struct uc_threadmsg **msg);
int uc_thread_queue_tryget(struct uc_threadqueue *queue,
const struct timespec *timeout,
struct uc_threadmsg **msg);
/**
* Like uc_thread_queue_tryget, but will wait indefintly for an item
* to become available
* @see uc_thread_queue_tryget
*/
static inline int uc_thread_queue_get(struct uc_threadqueue *queue, struct uc_threadmsg **msg)
static inline int uc_thread_queue_get(struct uc_threadqueue *queue,
struct uc_threadmsg **msg)
{
return uc_thread_queue_tryget(queue, NULL, msg);
}
@@ -246,7 +252,9 @@ unsigned int uc_thread_queue_length( struct uc_threadqueue *queue );
* @param cookie pointer passed back to the uc_thread_queue_walk_func
* @return 0 on success EINVAL if queue is NULL EBUSY if someone is holding any locks on the queue
*/
int uc_thread_queue_destroy(struct uc_threadqueue *queue, uc_thread_queue_walk_func free_func, void *cookie);
int uc_thread_queue_destroy(struct uc_threadqueue *queue,
uc_thread_queue_walk_func free_func,
void *cookie);
/**
* Walk the elements of the queue, intended for debugging
@@ -261,7 +269,9 @@ int uc_thread_queue_destroy(struct uc_threadqueue *queue, uc_thread_queue_walk_f
* The function must not in anyway interact with the queue.
* @return 0 on success
*/
int uc_thread_queue_walk(struct uc_threadqueue *queue, uc_thread_queue_walk_func walk_func, void *cookie);
int uc_thread_queue_walk(struct uc_threadqueue *queue,
uc_thread_queue_walk_func walk_func,
void *cookie);
/**
@@ -275,7 +285,9 @@ int uc_thread_queue_walk(struct uc_threadqueue *queue, uc_thread_queue_walk_func
* @param cookie pointer passed back to the uc_thread_queue_walk_func
* @return 0 on success
*/
int uc_thread_queue_clear(struct uc_threadqueue *queue, uc_thread_queue_walk_func free_func, void *cookie);
int uc_thread_queue_clear(struct uc_threadqueue *queue,
uc_thread_queue_walk_func free_func,
void *cookie);
/**
+3 -1
View File
@@ -32,7 +32,9 @@ int uc_ticket_lock_init(struct UCTicketLock *lock);
*
* @return 0 on success, errno value on failure
*/
int uc_ticket_lock_init_ex(struct UCTicketLock *lock, pthread_mutexattr_t *mattr, pthread_condattr_t *cattr);
int uc_ticket_lock_init_ex(struct UCTicketLock *lock,
pthread_mutexattr_t *mattr,
pthread_condattr_t *cattr);
/** Acquire the lock
*/
+11 -8
View File
@@ -46,8 +46,9 @@ typedef void (*uc_timer_cb)(struct UCTimers *timers, struct UCTimer *timer);
struct UCTimer {
//Internal members
RBNode rb_node; //the RBNode will hold a data pointer to the
//the UCTimer it's a member of. We might get rid of that member, and use CONTAINER_OF
//to find the UCTimer from a RBNode (Or just cast it, it's the 1. member..)
//the UCTimer it's a member of. We might get rid of that
//member, and use CONTAINER_OF to find the UCTimer from
//a RBNode (Or just cast it, it's the 1. member..)
//absolute time when the timer should be fired
struct timeval timeout;
@@ -73,7 +74,8 @@ struct UCTimers {
RBTree timer_tree;
struct UCoreClock *uclock;
size_t seq; //used to generate unique timers
TAILQ_HEAD(, UCTimer) ready_list; //pending timers to be fired while inside uc_timers_run
TAILQ_HEAD(, UCTimer) ready_list; //pending timers to be fired while
//inside uc_timers_run
};
/** Initialize a timer engine for use.
@@ -103,8 +105,8 @@ void uc_timers_init_ex(struct UCTimers *t, struct UCoreClock *uclock);
void uc_timers_add(struct UCTimers *timers, struct UCTimer *timer, int sec, int usec);
/** Remove a timer.
* Note, the timer memory must have been zeroed out or the timer must have been added at least once
* before uc_timers_remove can be called on a UCTimer.
* Note, the timer memory must have been zeroed out or the timer must have been
* added at least once before uc_timers_remove can be called on a UCTimer.
* uc_timers_remove does nothing if the timer has expired.
*
* @param timers timer engine to remove from
@@ -131,7 +133,8 @@ size_t uc_timers_count(const struct UCTimers *timers);
/** Check if a timer is running (i.e. hasn't expired and fired)
*
* @param timer timer to query
* @return 0 if the timer has expired (or was never added) non-0 if it's running (active or pending)
* @return 0 if the timer has expired (or was never added) non-0 if it's
* running (active or pending)
*/
int uc_timer_running(const struct UCTimer *timer);
@@ -141,8 +144,8 @@ int uc_timer_running(const struct UCTimer *timer);
* @param timers timer engine to run
* @param now The curent time. The engine will fire all timers whose expiry time is
* prior to this value.
* @return the number of timers fired, or negative if an error occured(presently no errors
* are possible and the return value is always >= 0
* @return the number of timers fired, or negative if an error occured(presently
* no errors are possible and the return value is always >= 0
**/
int uc_timers_run(struct UCTimers *timers);
+2 -2
View File
@@ -3,7 +3,7 @@
static void
uc_sift(unsigned char *base, size_t start, size_t count, size_t width,
uc_hs_cmp cmp, uc_hs_swp swap, void *cookie)
i uc_hs_cmp cmp, uc_hs_swp swap, void *cookie)
{
size_t root = start, child;
@@ -27,7 +27,7 @@ uc_sift(unsigned char *base, size_t start, size_t count, size_t width,
void
uc_heapsort(void *base_, size_t count, size_t width,
uc_hs_cmp cmp, uc_hs_swp swap, void *cookie)
uc_hs_cmp cmp, uc_hs_swp swap, void *cookie)
{
long start;
long end;
+4 -1
View File
@@ -28,7 +28,10 @@ uc_hex_encode(const uint8_t *restrict in, size_t len, char *restrict out)
}
char*
uc_hex_encode_delim(const uint8_t *restrict in, size_t inlen, char *restrict out, int outlen, const char *restrict delim)
uc_hex_encode_delim(
const uint8_t *restrict in, size_t inlen,
char *restrict out, int outlen,
const char *restrict delim)
{
size_t i;
char *outp = out;
+4 -1
View File
@@ -198,7 +198,10 @@ struct UCLogDestination *uc_log_new_stderr(enum UC_LOG_LEVEL log_level, int log_
return dest;
}
struct UCLogDestination *uc_log_new_syslog(const char *ident, int facility, enum UC_LOG_LEVEL log_level, int log_location)
struct UCLogDestination *uc_log_new_syslog(const char *ident,
int facility,
enum UC_LOG_LEVEL log_level,
int log_location)
{
struct UCLogDestination *dest = calloc(1, sizeof *dest);
char *id;
+5 -1
View File
@@ -40,7 +40,11 @@ uint8_t *uc_mbuf_pull(struct MBuf *mbuf, uint32_t size)
return data;
}
void uc_mbuf_init(struct MBuf *mbuf, uint8_t *restrict buf, uint32_t len, uint32_t headroom, uint32_t flags)
void uc_mbuf_init(struct MBuf *mbuf,
uint8_t *restrict buf,
uint32_t len,
uint32_t headroom,
uint32_t flags)
{
mbuf->bufstart = buf;
mbuf->p1 = mbuf->p2 = mbuf->p3 = mbuf->p4 = NULL;
+1 -2
View File
@@ -20,8 +20,7 @@ static UCRCResult uc_restart_counter_lock(int fd)
return UC_RC_OK;
}
UCRCResult uc_restart_counter_init(
struct UCRestartCounter *counter,
UCRCResult uc_restart_counter_init(struct UCRestartCounter *counter,
const char *filename,
unsigned int flags)
{
+10 -5
View File
@@ -66,18 +66,22 @@ again:
}
if (WIFSIGNALED(status)) {
syslog(LOG_ERR, "supervised process(pid %ld) exited cause of signal %d, status = 0x%X", (long)pid, WTERMSIG(status), status);
syslog(LOG_ERR, "supervised process(pid %ld) exited cause of signal %d, status = 0x%X",
(long)pid, WTERMSIG(status), status);
return RESTART;
} else if (WIFEXITED(status)) {
syslog(LOG_ERR, "supervised process(pid %ld) exited with code %d, status = 0x%X", (long)pid, WTERMSIG(status), status);
syslog(LOG_ERR, "supervised process(pid %ld) exited with code %d, status = 0x%X",
(long)pid, WTERMSIG(status), status);
return RESTART;
}
/* Ok, can we ever get here ? */
syslog(LOG_ERR, "waitpid of supervised process(pid %ld) status = 0x%X", (long)pid, status);
syslog(LOG_ERR, "waitpid of supervised process(pid %ld) status = 0x%X",
(long)pid, status);
if (kill(pid, 0) == 0) {
syslog(LOG_ERR, "supervised process(pid %ld) seems to still be alive, not restarting", (long)pid);
syslog(LOG_ERR, "supervised process(pid %ld) seems to still be alive, not restarting",
(long)pid);
goto again;
}
@@ -134,7 +138,8 @@ int uc_supervise(void)
switch (cmd) {
case CLEAN_EXIT:
syslog(LOG_INFO, "Terminating supervised pid %lu", (unsigned long)pid);
syslog(LOG_INFO, "Terminating supervised pid %lu",
(unsigned long)pid);
kill_supervised_process(pid);
wait(NULL);
syslog(LOG_INFO, "Exiting");
+2 -2
View File
@@ -281,8 +281,8 @@ unsigned int uc_thread_queue_length(struct uc_threadqueue *queue)
}
int uc_thread_queue_clear(struct uc_threadqueue *queue,
uc_thread_queue_walk_func free_func,
void *cookie)
uc_thread_queue_walk_func free_func,
void *cookie)
{
if (queue == NULL) {
return EINVAL;
+3 -1
View File
@@ -13,7 +13,9 @@ int uc_ticket_lock_init(struct UCTicketLock *lock)
return uc_ticket_lock_init_ex(lock, NULL, NULL);
}
int uc_ticket_lock_init_ex(struct UCTicketLock *lock, pthread_mutexattr_t *mattr, pthread_condattr_t *cattr)
int uc_ticket_lock_init_ex(struct UCTicketLock *lock,
pthread_mutexattr_t *mattr,
pthread_condattr_t *cattr)
{
int rc;
lock->queue_head = 0;