mirror of
git://sigrok.org/libserialport
synced 2023-08-10 21:13:24 +03:00
Tidy up static functions.
This commit is contained in:
parent
8f471c669f
commit
348e23ccbb
16
serialport.c
16
serialport.c
@ -91,7 +91,9 @@ const struct std_baudrate std_baudrates[] = {
|
|||||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||||
#define NUM_STD_BAUDRATES ARRAY_SIZE(std_baudrates)
|
#define NUM_STD_BAUDRATES ARRAY_SIZE(std_baudrates)
|
||||||
|
|
||||||
/* Helper functions for configuring ports. */
|
/* Helper functions. */
|
||||||
|
static int validate_port(struct sp_port *port);
|
||||||
|
static struct sp_port **list_append(struct sp_port **list, const char *portname);
|
||||||
static int get_config(struct sp_port *port, struct sp_port_data *data, struct sp_port_config *config);
|
static int get_config(struct sp_port *port, struct sp_port_data *data, struct sp_port_config *config);
|
||||||
static int set_config(struct sp_port *port, struct sp_port_data *data, struct sp_port_config *config);
|
static int set_config(struct sp_port *port, struct sp_port_data *data, struct sp_port_config *config);
|
||||||
|
|
||||||
@ -156,7 +158,7 @@ void sp_free_port(struct sp_port *port)
|
|||||||
free(port);
|
free(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct sp_port **sp_list_append(struct sp_port **list, const char *portname)
|
static struct sp_port **list_append(struct sp_port **list, const char *portname)
|
||||||
{
|
{
|
||||||
void *tmp;
|
void *tmp;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
@ -240,7 +242,7 @@ int sp_list_ports(struct sp_port ***list_ptr)
|
|||||||
#else
|
#else
|
||||||
strcpy(name, data);
|
strcpy(name, data);
|
||||||
#endif
|
#endif
|
||||||
if (type == REG_SZ && !(list = sp_list_append(list, name)))
|
if (type == REG_SZ && !(list = list_append(list, name)))
|
||||||
{
|
{
|
||||||
ret = SP_ERR_MEM;
|
ret = SP_ERR_MEM;
|
||||||
goto out;
|
goto out;
|
||||||
@ -298,7 +300,7 @@ out_done:
|
|||||||
result = CFStringGetCString(cf_path,
|
result = CFStringGetCString(cf_path,
|
||||||
path, PATH_MAX, kCFStringEncodingASCII);
|
path, PATH_MAX, kCFStringEncodingASCII);
|
||||||
CFRelease(cf_path);
|
CFRelease(cf_path);
|
||||||
if (result && !(list = sp_list_append(list, path)))
|
if (result && !(list = list_append(list, path)))
|
||||||
{
|
{
|
||||||
ret = SP_ERR_MEM;
|
ret = SP_ERR_MEM;
|
||||||
IOObjectRelease(port);
|
IOObjectRelease(port);
|
||||||
@ -357,7 +359,7 @@ out_done:
|
|||||||
if (serial_info.type == PORT_UNKNOWN)
|
if (serial_info.type == PORT_UNKNOWN)
|
||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
list = sp_list_append(list, name);
|
list = list_append(list, name);
|
||||||
skip:
|
skip:
|
||||||
udev_device_unref(ud_dev);
|
udev_device_unref(ud_dev);
|
||||||
if (!list)
|
if (!list)
|
||||||
@ -395,7 +397,7 @@ void sp_free_port_list(struct sp_port **list)
|
|||||||
free(list);
|
free(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sp_validate_port(struct sp_port *port)
|
static int validate_port(struct sp_port *port)
|
||||||
{
|
{
|
||||||
if (port == NULL)
|
if (port == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
@ -409,7 +411,7 @@ static int sp_validate_port(struct sp_port *port)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_PORT() do { if (!sp_validate_port(port)) return SP_ERR_ARG; } while (0)
|
#define CHECK_PORT() do { if (!validate_port(port)) return SP_ERR_ARG; } while (0)
|
||||||
|
|
||||||
int sp_open(struct sp_port *port, int flags)
|
int sp_open(struct sp_port *port, int flags)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user