Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 914a9dcd authored by Myles Watson's avatar Myles Watson
Browse files

osi: Apply clang-format

cd osi/
clang-format -i --style=file include/*.h include/socket_utils/* src/*.cc \
    src/socket_utils/* src/protos/* test/*

Test: mma -j32
Change-Id: I659e586076f1e2ec8f687cd33f441700b8d1f823
parent 35430799
Loading
Loading
Loading
Loading
+13 −14
Original line number Diff line number Diff line
@@ -75,8 +75,8 @@ void alarm_free(alarm_t *alarm);
// thread is not same as the caller’s thread. If two (or more)
// alarms are set back-to-back with the same |interval_ms|, the
// callbacks will be called in the order the alarms are set.
void alarm_set(alarm_t *alarm, period_ms_t interval_ms,
               alarm_callback_t cb, void *data);
void alarm_set(alarm_t* alarm, period_ms_t interval_ms, alarm_callback_t cb,
               void* data);

// Sets an |alarm| to execute a callback in the future on a
// specific |queue|. This function is same as |alarm_set| except
@@ -86,8 +86,7 @@ void alarm_set(alarm_t *alarm, period_ms_t interval_ms,
// among alarms that are scheduled on the same queue. |queue|
// may not be NULL.
void alarm_set_on_queue(alarm_t* alarm, period_ms_t interval_ms,
                        alarm_callback_t cb, void *data,
                        fixed_queue_t *queue);
                        alarm_callback_t cb, void* data, fixed_queue_t* queue);

// This function cancels the |alarm| if it was previously set.
// When this call returns, the caller has a guarantee that the
+5 −3
Original line number Diff line number Diff line
@@ -48,7 +48,8 @@ size_t allocation_tracker_expect_no_allocations(void);
// enough memory for canaries; the total allocation size can be determined
// by calling |allocation_tracker_resize_for_canary|. Returns |ptr| offset
// to the the beginning of the uncanaried region.
void *allocation_tracker_notify_alloc(allocator_id_t allocator_id, void *ptr, size_t requested_size);
void* allocation_tracker_notify_alloc(allocator_id_t allocator_id, void* ptr,
                                      size_t requested_size);

// Notify the tracker of an allocation that is being freed. |ptr| must be a
// pointer returned by a call to |allocation_tracker_notify_alloc| with the
@@ -57,7 +58,8 @@ void *allocation_tracker_notify_alloc(allocator_id_t allocator_id, void *ptr, si
// space.
void* allocation_tracker_notify_free(allocator_id_t allocator_id, void* ptr);

// Get the full size for an allocation, taking into account the size of canaries.
// Get the full size for an allocation, taking into account the size of
// canaries.
size_t allocation_tracker_resize_for_canary(size_t size);

#ifdef __cplusplus
+19 −13
Original line number Diff line number Diff line
@@ -28,18 +28,22 @@ extern "C" {

typedef struct array_t array_t;

// Returns a new array object that stores elements of size |element_size|. The returned
// object must be freed with |array_free|. |element_size| must be greater than 0. Returns
// Returns a new array object that stores elements of size |element_size|. The
// returned
// object must be freed with |array_free|. |element_size| must be greater than
// 0. Returns
// NULL on failure.
array_t* array_new(size_t element_size);

// Frees an array that was allocated with |array_new|. |array| may be NULL.
void array_free(array_t* array);

// Returns a pointer to the first stored element in |array|. |array| must not be NULL.
// Returns a pointer to the first stored element in |array|. |array| must not be
// NULL.
void* array_ptr(const array_t* array);

// Returns a pointer to the |index|th element of |array|. |index| must be less than
// Returns a pointer to the |index|th element of |array|. |index| must be less
// than
// the array's length. |array| must not be NULL.
void* array_at(const array_t* array, size_t index);

@@ -55,8 +59,10 @@ size_t array_length(const array_t *array);
bool array_append_value(array_t* array, uint32_t value);

// Inserts an element to the end of |array|. The value pointed to by |data| must
// be at least |element_size| bytes long and will be copied into the array. Neither
// |array| nor |data| may be NULL. Returns true if the element could be inserted into
// be at least |element_size| bytes long and will be copied into the array.
// Neither
// |array| nor |data| may be NULL. Returns true if the element could be inserted
// into
// the array, false on error.
bool array_append_ptr(array_t* array, void* data);

+8 −7
Original line number Diff line number Diff line
@@ -35,7 +35,8 @@ buffer_t *buffer_new(size_t size);
// Creates a new reference to the buffer |buf|. A reference is indistinguishable
// from the original: writes to the original will be reflected in the reference
// and vice versa. In other words, this function creates an alias to |buf|. The
// caller must release the returned buffer with |buffer_free|. Note that releasing
// caller must release the returned buffer with |buffer_free|. Note that
// releasing
// the returned buffer does not release |buf|. |buf| must not be NULL.
buffer_t* buffer_new_ref(const buffer_t* buf);

+65 −39
Original line number Diff line number Diff line
@@ -62,80 +62,106 @@ bool config_has_section(const config_t *config, const char *section);

// Returns true if the config file has a key named |key| under |section|.
// Returns false otherwise. |config|, |section|, and |key| must not be NULL.
bool config_has_key(const config_t *config, const char *section, const char *key);
bool config_has_key(const config_t* config, const char* section,
                    const char* key);

// Returns the integral value for a given |key| in |section|. If |section|
// or |key| do not exist, or the value cannot be fully converted to an integer,
// this function returns |def_value|. |config|, |section|, and |key| must not
// be NULL.
int config_get_int(const config_t *config, const char *section, const char *key, int def_value);
int config_get_int(const config_t* config, const char* section, const char* key,
                   int def_value);

// Returns the boolean value for a given |key| in |section|. If |section|
// or |key| do not exist, or the value cannot be converted to a boolean, this
// function returns |def_value|. |config|, |section|, and |key| must not be NULL.
bool config_get_bool(const config_t *config, const char *section, const char *key, bool def_value);
// function returns |def_value|. |config|, |section|, and |key| must not be
// NULL.
bool config_get_bool(const config_t* config, const char* section,
                     const char* key, bool def_value);

// Returns the string value for a given |key| in |section|. If |section| or
// |key| do not exist, this function returns |def_value|. The returned string
// is owned by the config module and must not be freed. |config|, |section|,
// and |key| must not be NULL. |def_value| may be NULL.
const char *config_get_string(const config_t *config, const char *section, const char *key, const char *def_value);
const char* config_get_string(const config_t* config, const char* section,
                              const char* key, const char* def_value);

// Sets an integral value for the |key| in |section|. If |key| or |section| do
// not already exist, this function creates them. |config|, |section|, and |key|
// must not be NULL.
void config_set_int(config_t *config, const char *section, const char *key, int value);
void config_set_int(config_t* config, const char* section, const char* key,
                    int value);

// Sets a boolean value for the |key| in |section|. If |key| or |section| do
// not already exist, this function creates them. |config|, |section|, and |key|
// must not be NULL.
void config_set_bool(config_t *config, const char *section, const char *key, bool value);
void config_set_bool(config_t* config, const char* section, const char* key,
                     bool value);

// Sets a string value for the |key| in |section|. If |key| or |section| do
// not already exist, this function creates them. |config|, |section|, |key|, and
// not already exist, this function creates them. |config|, |section|, |key|,
// and
// |value| must not be NULL.
void config_set_string(config_t *config, const char *section, const char *key, const char *value);
void config_set_string(config_t* config, const char* section, const char* key,
                       const char* value);

// Removes |section| from the |config| (and, as a result, all keys in the section).
// Returns true if |section| was found and removed from |config|, false otherwise.
// Removes |section| from the |config| (and, as a result, all keys in the
// section).
// Returns true if |section| was found and removed from |config|, false
// otherwise.
// Neither |config| nor |section| may be NULL.
bool config_remove_section(config_t* config, const char* section);

// Removes one specific |key| residing in |section| of the |config|. Returns true
// Removes one specific |key| residing in |section| of the |config|. Returns
// true
// if the section and key were found and the key was removed, false otherwise.
// None of |config|, |section|, or |key| may be NULL.
bool config_remove_key(config_t* config, const char* section, const char* key);

// Returns an iterator to the first section in the config file. If there are no
// sections, the iterator will equal the return value of |config_section_end|.
// The returned pointer must be treated as an opaque handle and must not be freed.
// The iterator is invalidated on any config mutating operation. |config| may not
// The returned pointer must be treated as an opaque handle and must not be
// freed.
// The iterator is invalidated on any config mutating operation. |config| may
// not
// be NULL.
const config_section_node_t* config_section_begin(const config_t* config);

// Returns an iterator to one past the last section in the config file. It does not
// represent a valid section, but can be used to determine if all sections have been
// iterated over. The returned pointer must be treated as an opaque handle and must
// not be freed and must not be iterated on (must not call |config_section_next| on
// Returns an iterator to one past the last section in the config file. It does
// not
// represent a valid section, but can be used to determine if all sections have
// been
// iterated over. The returned pointer must be treated as an opaque handle and
// must
// not be freed and must not be iterated on (must not call |config_section_next|
// on
// it). |config| may not be NULL.
const config_section_node_t* config_section_end(const config_t* config);

// Moves |iter| to the next section. If there are no more sections, |iter| will
// equal the value of |config_section_end|. |iter| may not be NULL and must be
// a pointer returned by either |config_section_begin| or |config_section_next|.
const config_section_node_t *config_section_next(const config_section_node_t *iter);

// Returns the name of the section referred to by |iter|. The returned pointer is
// owned by the config module and must not be freed by the caller. The pointer will
// remain valid until |config_free| is called. |iter| may not be NULL and must not
const config_section_node_t* config_section_next(
    const config_section_node_t* iter);

// Returns the name of the section referred to by |iter|. The returned pointer
// is
// owned by the config module and must not be freed by the caller. The pointer
// will
// remain valid until |config_free| is called. |iter| may not be NULL and must
// not
// equal the value returned by |config_section_end|.
const char* config_section_name(const config_section_node_t* iter);

// Saves |config| to a file given by |filename|. Note that this could be a destructive
// Saves |config| to a file given by |filename|. Note that this could be a
// destructive
// operation: if |filename| already exists, it will be overwritten. The config
// module does not preserve comments or formatting so if a config file was opened
// with |config_new| and subsequently overwritten with |config_save|, all comments
// and special formatting in the original file will be lost. Neither |config| nor
// module does not preserve comments or formatting so if a config file was
// opened
// with |config_new| and subsequently overwritten with |config_save|, all
// comments
// and special formatting in the original file will be lost. Neither |config|
// nor
// |filename| may be NULL.
bool config_save(const config_t* config, const char* filename);

Loading