1
0
mirror of git://sigrok.org/libserialport synced 2023-08-10 21:13:24 +03:00

Return SP_ERR_SUPP from sp_list_ports() on unsupported platforms.

This commit is contained in:
Martin Ling
2013-11-23 11:57:17 +00:00
parent 64690702cb
commit 6b93ede419
2 changed files with 14 additions and 5 deletions

View File

@@ -246,7 +246,7 @@ fail:
enum sp_return sp_list_ports(struct sp_port ***list_ptr)
{
struct sp_port **list;
int ret = SP_OK;
int ret = SP_ERR_SUPP;
TRACE("%p", list_ptr);
@@ -269,6 +269,8 @@ enum sp_return sp_list_ports(struct sp_port ***list_ptr)
char *name;
int name_len;
ret = SP_OK;
DEBUG("Opening registry key");
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("HARDWARE\\DEVICEMAP\\SERIALCOMM"),
0, KEY_QUERY_VALUE, &key) != ERROR_SUCCESS) {
@@ -339,6 +341,8 @@ out_done:
CFTypeRef cf_path;
Boolean result;
ret = SP_OK;
DEBUG("Getting IOKit master port");
if (IOMasterPort(MACH_PORT_NULL, &master) != KERN_SUCCESS) {
SET_FAIL(ret, "IOMasterPort() failed");
@@ -402,6 +406,8 @@ out_done:
int fd, ioctl_result;
struct serial_struct serial_info;
ret = SP_OK;
DEBUG("Enumerating tty devices");
ud = udev_new();
ud_enumerate = udev_enumerate_new(ud);
@@ -456,10 +462,13 @@ out:
udev_unref(ud);
#endif
if (ret == SP_OK) {
switch (ret) {
case SP_OK:
*list_ptr = list;
RETURN_OK();
} else {
case SP_ERR_SUPP:
DEBUG_ERROR(SP_ERR_SUPP, "Enumeration not supported on this platform.");
default:
if (list)
sp_free_port_list(list);
*list_ptr = NULL;