* @param path Path to the gpiochip device file.
* @return GPIO chip handle or NULL if an error occurred.
*/
-struct gpiod_chip * gpiod_chip_open(const char *path) GPIOD_API;
+struct gpiod_chip *gpiod_chip_open(const char *path) GPIOD_API;
/**
* @brief Open a gpiochip by name.
*
* This routine appends name to '/dev/' to create the path.
*/
-struct gpiod_chip * gpiod_chip_open_by_name(const char *name) GPIOD_API;
+struct gpiod_chip *gpiod_chip_open_by_name(const char *name) GPIOD_API;
/**
* @brief Open a gpiochip by number.
*
* This routine appends num to '/dev/gpiochip' to create the path.
*/
-struct gpiod_chip * gpiod_chip_open_by_number(unsigned int num) GPIOD_API;
+struct gpiod_chip *gpiod_chip_open_by_number(unsigned int num) GPIOD_API;
/**
* @brief Open a gpiochip by label.
* @note If the chip cannot be found but no other error occurred, errno is set
* to ENOENT.
*/
-struct gpiod_chip * gpiod_chip_open_by_label(const char *label) GPIOD_API;
+struct gpiod_chip *gpiod_chip_open_by_label(const char *label) GPIOD_API;
/**
* @brief Open a gpiochip based on the best guess what the path is.
* GPIO chip, its name, label or number as a string. Then it tries to open it
* using one of the gpiod_chip_open** variants.
*/
-struct gpiod_chip * gpiod_chip_open_lookup(const char *descr) GPIOD_API;
+struct gpiod_chip *gpiod_chip_open_lookup(const char *descr) GPIOD_API;
/**
* @brief Close a GPIO chip handle and release all allocated resources.
* @param chip The GPIO chip object.
* @return Pointer to a human-readable string containing the chip name.
*/
-const char * gpiod_chip_name(struct gpiod_chip *chip) GPIOD_API;
+const char *gpiod_chip_name(struct gpiod_chip *chip) GPIOD_API;
/**
* @brief Get the GPIO chip label as represented in the kernel.
* @param chip The GPIO chip object.
* @return Pointer to a human-readable string containing the chip label.
*/
-const char * gpiod_chip_label(struct gpiod_chip *chip) GPIOD_API;
+const char *gpiod_chip_label(struct gpiod_chip *chip) GPIOD_API;
/**
* @brief Get the number of GPIO lines exposed by this chip.
* routine returns a pointer to a null-terminated string or NULL if
* the line is unnamed.
*/
-const char * gpiod_line_name(struct gpiod_line *line) GPIOD_API;
+const char *gpiod_line_name(struct gpiod_line *line) GPIOD_API;
/**
* @brief Read the GPIO line consumer name.
* kernel. This routine returns a pointer to a null-terminated string
* or NULL if the line is not used.
*/
-const char * gpiod_line_consumer(struct gpiod_line *line) GPIOD_API;
+const char *gpiod_line_consumer(struct gpiod_line *line) GPIOD_API;
/**
* @brief Read the GPIO line direction setting.
* this line to avoid memory leaks. If the line could not be found, this
* functions sets errno to ENOENT.
*/
-struct gpiod_line * gpiod_line_find(const char *name) GPIOD_API;
+struct gpiod_line *gpiod_line_find(const char *name) GPIOD_API;
/**
* @brief Close a GPIO chip owning this line and release all resources.
* @param line The GPIO line object.
* @return Pointer to the GPIO chip handle controlling this line.
*/
-struct gpiod_chip * gpiod_line_get_chip(struct gpiod_line *line) GPIOD_API;
+struct gpiod_chip *gpiod_line_get_chip(struct gpiod_line *line) GPIOD_API;
/**
* @}
* files, opens them and stores their the handles until ::gpiod_chip_iter_free
* or ::gpiod_chip_iter_free_noclose is called.
*/
-struct gpiod_chip_iter * gpiod_chip_iter_new(void) GPIOD_API;
+struct gpiod_chip_iter *gpiod_chip_iter_new(void) GPIOD_API;
/**
* @brief Release all resources allocated for the gpiochip iterator and close
* @brief Get the version of the library as a human-readable string.
* @return Human-readable string containing the library version.
*/
-const char * gpiod_version_string(void) GPIOD_API;
+const char *gpiod_version_string(void) GPIOD_API;
/**
* @}
char label[32];
};
-struct gpiod_chip * gpiod_chip_open(const char *path)
+struct gpiod_chip *gpiod_chip_open(const char *path)
{
struct gpiochip_info info;
struct gpiod_chip *chip;
free(chip);
}
-const char * gpiod_chip_name(struct gpiod_chip *chip)
+const char *gpiod_chip_name(struct gpiod_chip *chip)
{
return chip->name;
}
-const char * gpiod_chip_label(struct gpiod_chip *chip)
+const char *gpiod_chip_label(struct gpiod_chip *chip)
{
return chip->label;
}
line->up_to_date = false;
}
-struct gpiod_chip * gpiod_line_get_chip(struct gpiod_line *line)
+struct gpiod_chip *gpiod_line_get_chip(struct gpiod_line *line)
{
return line->chip;
}
return line->offset;
}
-const char * gpiod_line_name(struct gpiod_line *line)
+const char *gpiod_line_name(struct gpiod_line *line)
{
return line->name[0] == '\0' ? NULL : line->name;
}
-const char * gpiod_line_consumer(struct gpiod_line *line)
+const char *gpiod_line_consumer(struct gpiod_line *line)
{
return line->consumer[0] == '\0' ? NULL : line->consumer;
}
if (!line_bulk_same_chip(bulk) || !line_bulk_all_free(bulk))
return -1;
- if (line_request_is_direction(config->request_type)) {
+ if (line_request_is_direction(config->request_type))
return line_request_values(bulk, config, default_vals);
- } else if (line_request_is_events(config->request_type)) {
+ else if (line_request_is_events(config->request_type))
return line_request_events(bulk, config);
- }
errno = EINVAL;
return -1;
static bool isuint(const char *str)
{
- for (; *str && isdigit(*str); str++);
+ for (; *str && isdigit(*str); str++)
+ ;
return *str == '\0';
}
-struct gpiod_chip * gpiod_chip_open_by_name(const char *name)
+struct gpiod_chip *gpiod_chip_open_by_name(const char *name)
{
struct gpiod_chip *chip;
char *path;
return chip;
}
-struct gpiod_chip * gpiod_chip_open_by_number(unsigned int num)
+struct gpiod_chip *gpiod_chip_open_by_number(unsigned int num)
{
struct gpiod_chip *chip;
char *path;
return chip;
}
-struct gpiod_chip * gpiod_chip_open_by_label(const char *label)
+struct gpiod_chip *gpiod_chip_open_by_label(const char *label)
{
struct gpiod_chip_iter *iter;
struct gpiod_chip *chip;
return NULL;
}
-struct gpiod_chip * gpiod_chip_open_lookup(const char *descr)
+struct gpiod_chip *gpiod_chip_open_lookup(const char *descr)
{
struct gpiod_chip *chip;
GPIOD_LINE_REQUEST_EVENT_BOTH_EDGES);
}
-struct gpiod_line * gpiod_line_get(const char *device, unsigned int offset)
+struct gpiod_line *gpiod_line_get(const char *device, unsigned int offset)
{
struct gpiod_chip *chip;
struct gpiod_line *line;
return line;
}
-struct gpiod_line * gpiod_line_find(const char *name)
+struct gpiod_line *gpiod_line_find(const char *name)
{
struct gpiod_chip_iter *iter;
struct gpiod_chip *chip;
free(*dirs);
}
-struct gpiod_chip_iter * gpiod_chip_iter_new(void)
+struct gpiod_chip_iter *gpiod_chip_iter_new(void)
{
struct gpiod_chip_iter *iter;
struct dirent **dirs;
free(iter);
}
-struct gpiod_chip * gpiod_chip_iter_next(struct gpiod_chip_iter *iter)
+struct gpiod_chip *gpiod_chip_iter_next(struct gpiod_chip_iter *iter)
{
if (iter->offset > 0) {
gpiod_chip_close(iter->chips[iter->offset - 1]);
return gpiod_chip_iter_next_noclose(iter);
}
-struct gpiod_chip * gpiod_chip_iter_next_noclose(struct gpiod_chip_iter *iter)
+struct gpiod_chip *gpiod_chip_iter_next_noclose(struct gpiod_chip_iter *iter)
{
return iter->offset < (iter->num_chips)
? iter->chips[iter->offset++] : NULL;
}
-struct gpiod_line_iter * gpiod_line_iter_new(struct gpiod_chip *chip)
+struct gpiod_line_iter *gpiod_line_iter_new(struct gpiod_chip *chip)
{
struct gpiod_line_iter *iter;
unsigned int i;
free(iter);
}
-struct gpiod_line * gpiod_line_iter_next(struct gpiod_line_iter *iter)
+struct gpiod_line *gpiod_line_iter_next(struct gpiod_line_iter *iter)
{
return iter->offset < (iter->num_lines)
? iter->lines[iter->offset++] : NULL;
#include <gpiod.h>
-const char * gpiod_version_string(void)
+const char *gpiod_version_string(void)
{
return GPIOD_VERSION_STR;
}
#include <getopt.h>
#include <errno.h>
+typedef bool (*is_set_func)(struct gpiod_line *);
+
struct flag {
const char *name;
- bool (*is_set)(struct gpiod_line *);
+ is_set_func is_set;
};
static const struct flag flags[] = {
},
};
-static const struct mode_mapping * parse_mode(const char *mode)
+static const struct mode_mapping *parse_mode(const char *mode)
{
unsigned int i;
CYELLOW,
};
-static const char *term_colors[] = {
+static const char *const term_colors[] = {
"\033[0m",
"\033[32m",
"\033[31m",
exit(EXIT_FAILURE);
}
-static MALLOC void * xmalloc(size_t size)
+static MALLOC void *xmalloc(size_t size)
{
void *ptr;
return ptr;
}
-static MALLOC void * xzalloc(size_t size)
+static MALLOC void *xzalloc(size_t size)
{
void *ptr;
return ptr;
}
-static MALLOC void * xcalloc(size_t nmemb, size_t size)
+static MALLOC void *xcalloc(size_t nmemb, size_t size)
{
void *ptr;
return ptr;
}
-static MALLOC char * xstrdup(const char *str)
+static MALLOC char *xstrdup(const char *str)
{
char *ret;
return ret;
}
-static TEST_PRINTF(2, 3) char * xappend(char *str, const char *fmt, ...)
+static TEST_PRINTF(2, 3) char *xappend(char *str, const char *fmt, ...)
{
char *new, *ret;
va_list va;
pthread_mutex_unlock(&globals.test_ctx.event.lock);
}
-static void * event_worker(void *data TEST_UNUSED)
+static void *event_worker(void *data TEST_UNUSED)
{
struct event_thread *ev = &globals.test_ctx.event;
struct timeval tv_now, tv_add, tv_res;
}
}
-static char * gpiotool_proc_get_path(const char *tool)
+static char *gpiotool_proc_get_path(const char *tool)
{
char *path, *progpath, *progdir;
va_list va2;
va_copy(va2, va);
- for (num_args = 2; va_arg(va2, char *) != NULL; num_args++);
+ for (num_args = 2; va_arg(va2, char *) != NULL; num_args++)
+ ;
va_end(va2);
argv = xcalloc(num_args, sizeof(char *));
proc->running = false;
}
-const char * test_tool_stdout(void)
+const char *test_tool_stdout(void)
{
struct gpiotool_proc *proc = &globals.test_ctx.tool_proc;
return proc->stdout;
}
-const char * test_tool_stderr(void)
+const char *test_tool_stderr(void)
{
struct gpiotool_proc *proc = &globals.test_ctx.tool_proc;
gpiod_chip_iter_free_noclose(*iter);
}
-const char * test_chip_path(unsigned int index)
+const char *test_chip_path(unsigned int index)
{
check_chip_index(index);
return globals.test_ctx.chips[index]->path;
}
-const char * test_chip_name(unsigned int index)
+const char *test_chip_name(unsigned int index)
{
check_chip_index(index);
* or number by index corresponding with the order in which the mockup chips
* were requested in the TEST_DEFINE() macro.
*/
-const char * test_chip_path(unsigned int index);
-const char * test_chip_name(unsigned int index);
+const char *test_chip_path(unsigned int index);
+const char *test_chip_name(unsigned int index);
unsigned int test_chip_num(unsigned int index);
enum {
void test_tool_run(char *tool, ...);
void test_tool_wait(void);
-const char * test_tool_stdout(void);
-const char * test_tool_stderr(void);
+const char *test_tool_stdout(void);
+const char *test_tool_stderr(void);
bool test_tool_exited(void);
int test_tool_exit_status(void);
void test_tool_signal(int signum);