mesh: Make meshctl use bt_shell helpers
Luiz Augusto von Dentz
maintainerPATCH v2 1/1 mesh: Make meshctl use bt_shell helpers
From: Luiz Augusto von Dentz <[email protected]>
This makes meshctl use bt_shell to manage the menus and command handling.
--- mesh/config-client.c | 187 ++++++++--------- mesh/config-model.h | 1 - mesh/main.c | 571 +++++++++++++++------------------------------------ mesh/onoff-model.c | 88 +++----- mesh/util.c | 155 +------------- mesh/util.h | 16 +- 6 files changed, 278 insertions(+), 740 deletions(-)
mesh/config-client.c +81 -106
@@ -34,12 +34,11 @@#include <stdbool.h> #include <sys/uio.h> #include <wordexp.h> -#include <readline/readline.h> -#include <readline/history.h> +#include <glib.h> +#include "src/shared/shell.h" #include "src/shared/util.h" -#include "client/display.h" #include "mesh/mesh-net.h" #include "mesh/keys.h" #include "mesh/net.h"
@@ -101,12 +100,12 @@ static bool client_msg_recvd(uint16_t src, uint8_t *data,if (len !=4 )break ; -rl_printf ("Node %4.4x AppKey Status %s\n" , src, +bt_shell_printf ("Node %4.4x AppKey Status %s\n" , src,mesh_status_str (data[0 ])); net_idx =get_le16 (data +1 ) &0xfff ; app_idx =get_le16 (data +2 ) >>4 ; -rl_printf ("\tNetKey %3.3x, AppKey %3.3x\n" , net_idx, app_idx); +bt_shell_printf ("\tNetKey %3.3x, AppKey %3.3x\n" , net_idx, app_idx); if (data[0] != MESH_STATUS_SUCCESS && data[0] != MESH_STATUS_IDX_ALREADY_STORED &&
@@ -119,11 +118,11 @@ static bool client_msg_recvd(uint16_t src, uint8_t *data,if (len !=3 )break ; -rl_printf ("Node %4.4x NetKey Status %s\n" , src, +bt_shell_printf ("Node %4.4x NetKey Status %s\n" , src,mesh_status_str (data[0 ])); net_idx =get_le16 (data +1 ) &0xfff ; -rl_printf ("\tNetKey %3.3x\n" , net_idx); +bt_shell_printf ("\tNetKey %3.3x\n" , net_idx); if (data[0] != MESH_STATUS_SUCCESS && data[0] != MESH_STATUS_IDX_ALREADY_STORED &&
@@ -136,20 +135,20 @@ static bool client_msg_recvd(uint16_t src, uint8_t *data,if (len !=7 && len !=9 )break ; -rl_printf ("Node %4.4x Model App Status %s\n" , src, +bt_shell_printf ("Node %4.4x Model App Status %s\n" , src,mesh_status_str (data[0 ])); addr =get_le16 (data +1 ); app_idx =get_le16 (data +3 ); -rl_printf ("\tElement %4.4x AppIdx %3.3x\n " , addr, app_idx); +bt_shell_printf ("\tElement %4.4x AppIdx %3.3x\n " , addr, app_idx);if (len ==7 ) { mod_id =get_le16 (data +5 ); -rl_printf ("ModelId %4.4x\n" , mod_id); +bt_shell_printf ("ModelId %4.4x\n" , mod_id); mod_id =0xffff0000 | mod_id; }else { mod_id =get_le16 (data +7 ); -rl_printf ("ModelId %4.4x %4.4x\n" ,get_le16 (data +5 ), +bt_shell_printf ("ModelId %4.4x %4.4x\n" ,get_le16 (data +5 ), mod_id); mod_id =get_le16 (data +5 ) <<16 | mod_id; }
@@ -162,7 +161,7 @@ static bool client_msg_recvd(uint16_t src, uint8_t *data,case OP_CONFIG_DEFAULT_TTL_STATUS :if (len !=1 )return true; -rl_printf ("Node %4.4x Default TTL %d\n" , src, data[0 ]); +bt_shell_printf ("Node %4.4x Default TTL %d\n" , src, data[0 ]);if (node_set_default_ttl (node, data[0 ]))prov_db_node_set_ttl (node, data[0 ]);break ;
@@ -171,7 +170,7 @@ static bool client_msg_recvd(uint16_t src, uint8_t *data,if (len !=12 && len !=14 )return true; -rl_printf ("\nSet publication for node %4.4x status: %s\n" , src, +bt_shell_printf ("\nSet publication for node %4.4x status: %s\n" , src, data[0 ] ==MESH_STATUS_SUCCESS ?"Success" :mesh_status_str (data[0 ]));
@@ -192,22 +191,22 @@ static bool client_msg_recvd(uint16_t src, uint8_t *data, n = (data[8 ] &0x3f );switch (data[8 ] >>6 ) {case 0 : -rl_printf ("Period: %d ms\n" , n *100 ); +bt_shell_printf ("Period: %d ms\n" , n *100 );break ;case 2 : n *=10 ;/* fall through */ case 1 : -rl_printf ("Period: %d sec\n" , n); +bt_shell_printf ("Period: %d sec\n" , n);break ;case 3 : -rl_printf ("Period: %d min\n" , n *10 ); +bt_shell_printf ("Period: %d min\n" , n *10 );break ; } pub.retransmit = data[9 ]; -rl_printf ("Retransmit count: %d\n" , data[9 ] >>5 ); -rl_printf ("Retransmit Interval Steps: %d\n" , data[9 ] &0x1f ); +bt_shell_printf ("Retransmit count: %d\n" , data[9 ] >>5 ); +bt_shell_printf ("Retransmit Interval Steps: %d\n" , data[9 ] &0x1f ); ele_idx = ele_addr -node_get_primary (node);
@@ -226,45 +225,40 @@ static bool client_msg_recvd(uint16_t src, uint8_t *data,static uint32_t target;static uint32_t parms[8 ]; -static uint32_t read_input_parameters (const char *args) +static uint32_t read_input_parameters (int argc,char *argv[]) {uint32_t i; -if (!args) +if (!argc || argv[0 ][0 ] =='\0' )return 0 ;memset (parms,0xff ,sizeof (parms)); -for (i =0 ; i <sizeof (parms)/sizeof (parms[0 ]); i++) { -int n; - -sscanf (args,"%x" , &parms[i]); +for (i =0 ; i <sizeof (parms)/sizeof (parms[0 ]) && i < (unsigned ) argc; + i++) { +sscanf (argv[i],"%x" , &parms[i]);if (parms[i] ==0xffffffff )break ; - - n =strcspn (args," \t" ); - args = args + n +strspn (args + n," \t" ); }return i; } -static void cmd_set_node (const char *args) +static void cmd_set_node (int argc,char *argv[]) {uint32_t dst;char *end; - dst =strtol (args, &end,16 ); -if (end != (args +4 )) { -rl_printf ("Bad unicast address %s: " -"expected format 4 digit hex\n" , args); + dst =strtol (argv[0 ], &end,16 ); +if (end != (argv[0 ] +4 )) { +bt_shell_printf ("Bad unicast address %s: " +"expected format 4 digit hex\n" , argv[0 ]); target =UNASSIGNED_ADDRESS ; }else { -rl_printf ("Configuring node %4.4x\n" , dst); +bt_shell_printf ("Configuring node %4.4x\n" , dst); target = dst; -set_menu_prompt ("config" , args); +set_menu_prompt ("config" , argv[0 ]); } - }static bool config_send (uint8_t *buf,uint16_t len)
@@ -287,14 +281,14 @@ static bool config_send(uint8_t *buf, uint16_t len) } -static void cmd_get_composition (const char *args) +static void cmd_get_composition (int argc,char *argv[]) {uint16_t n;uint8_t msg[32 ];struct mesh_node *node;if (IS_UNASSIGNED (target)) { -rl_printf ("Destination not set\n" ); +bt_shell_printf ("Destination not set\n" );return ; }
@@ -306,13 +300,13 @@ static void cmd_get_composition(const char *args) n =mesh_opcode_set (OP_DEV_COMP_GET , msg);/* By default, use page 0 */ - msg[n++] = (read_input_parameters (args) ==1 ) ? parms[0 ] :0 ; + msg[n++] = (read_input_parameters (argc, argv) ==1 ) ? parms[0 ] :0 ;if (!config_send (msg, n)) -rl_printf ("Failed to send \"GET NODE COMPOSITION\"\n" ); +bt_shell_printf ("Failed to send \"GET NODE COMPOSITION\"\n" ); } -static void cmd_net_key (const char *args,uint32_t opcode) +static void cmd_net_key (int argc,char *argv[],uint32_t opcode) {uint16_t n;uint8_t msg[32 ];
@@ -321,20 +315,20 @@ static void cmd_net_key(const char *args, uint32_t opcode)struct mesh_node *node;if (IS_UNASSIGNED (target)) { -rl_printf ("Destination not set\n" ); +bt_shell_printf ("Destination not set\n" );return ; } n =mesh_opcode_set (opcode, msg); -if (read_input_parameters (args) !=1 ) { -rl_printf ("Bad arguments %s\n" , args); +if (read_input_parameters (argc, argv) !=1 ) { +bt_shell_printf ("Bad arguments %s\n" , argv[0 ]);return ; } node =node_find_by_addr (target);if (!node) { -rl_printf ("Node %4.4x\n not found" , target); +bt_shell_printf ("Node %4.4x\n not found" , target);return ; }
@@ -344,7 +338,7 @@ static void cmd_net_key(const char *args, uint32_t opcode) key =keys_net_key_get (net_idx, true);if (!key) { -rl_printf ("Network key with index %4.4x not found\n" , +bt_shell_printf ("Network key with index %4.4x not found\n" , net_idx);return ; }
@@ -357,7 +351,7 @@ static void cmd_net_key(const char *args, uint32_t opcode) }if (!config_send (msg, n)) { -rl_printf ("Failed to send \"%s NET KEY\"\n" , +bt_shell_printf ("Failed to send \"%s NET KEY\"\n" , opcode ==OP_NETKEY_ADD ?"ADD" :"DEL" );return ; }
@@ -374,17 +368,17 @@ static void cmd_net_key(const char *args, uint32_t opcode) } -static void cmd_add_net_key (const char *args) +static void cmd_add_net_key (int argc,char *argv[]) { -cmd_net_key (args,OP_NETKEY_ADD ); +cmd_net_key (argc, argv,OP_NETKEY_ADD ); } -static void cmd_del_net_key (const char *args) +static void cmd_del_net_key (int argc,char *argv[]) { -cmd_net_key (args,OP_NETKEY_DELETE ); +cmd_net_key (argc, argv,OP_NETKEY_DELETE ); } -static void cmd_app_key (const char *args,uint32_t opcode) +static void cmd_app_key (int argc,char *argv[],uint32_t opcode) {uint16_t n;uint8_t msg[32 ];
@@ -394,18 +388,18 @@ static void cmd_app_key(const char *args, uint32_t opcode)struct mesh_node *node;if (IS_UNASSIGNED (target)) { -rl_printf ("Destination not set\n" ); +bt_shell_printf ("Destination not set\n" );return ; } -if (read_input_parameters (args) !=1 ) { -rl_printf ("Bad arguments %s\n" , args); +if (read_input_parameters (argc, argv) !=1 ) { +bt_shell_printf ("Bad arguments %s\n" , argv[0 ]);return ; } node =node_find_by_addr (target);if (!node) { -rl_printf ("Node %4.4x\n not found" , target); +bt_shell_printf ("Node %4.4x\n not found" , target);return ; }
@@ -414,7 +408,7 @@ static void cmd_app_key(const char *args, uint32_t opcode) app_idx = parms[0 ]; net_idx =keys_app_key_get_bound (app_idx);if (net_idx ==NET_IDX_INVALID ) { -rl_printf ("App key with index %4.4x not found\n" , app_idx); +bt_shell_printf ("App key with index %4.4x not found\n" , app_idx);return ; }
@@ -426,7 +420,7 @@ static void cmd_app_key(const char *args, uint32_t opcode)if (opcode !=OP_APPKEY_DELETE ) { key =keys_app_key_get (app_idx, true);if (!key) { -rl_printf ("App key %4.4x not found\n" , net_idx); +bt_shell_printf ("App key %4.4x not found\n" , net_idx);return ; }
@@ -435,7 +429,7 @@ static void cmd_app_key(const char *args, uint32_t opcode) }if (!config_send (msg, n)) { -rl_printf ("Failed to send \"ADD %s KEY\"\n" , +bt_shell_printf ("Failed to send \"ADD %s KEY\"\n" , opcode ==OP_APPKEY_ADD ?"ADD" :"DEL" );return ; }
@@ -451,14 +445,14 @@ static void cmd_app_key(const char *args, uint32_t opcode) } } -static void cmd_add_app_key (const char *args) +static void cmd_add_app_key (int argc,char *argv[]) { -cmd_app_key (args,OP_APPKEY_ADD ); +cmd_app_key (argc, argv,OP_APPKEY_ADD ); } -static void cmd_del_app_key (const char *args) +static void cmd_del_app_key (int argc,char *argv[]) { -cmd_app_key (args,OP_APPKEY_DELETE ); +cmd_app_key (argc, argv,OP_APPKEY_DELETE ); }static bool verify_config_target (uint32_t dst)
@@ -466,25 +460,25 @@ static bool verify_config_target(uint32_t dst)struct mesh_node *node;if (IS_UNASSIGNED (dst)) { -rl_printf ("Destination not set\n" ); +bt_shell_printf ("Destination not set\n" );return false; } node =node_find_by_addr (dst);if (!node) { -rl_printf ("Node with unicast address %4.4x unknown\n" , dst); +bt_shell_printf ("Node with unicast address %4.4x unknown\n" , dst);return false; }if (!node_get_composition (node)) { -rl_printf ("Node composition for %4.4x unknown\n" , dst); +bt_shell_printf ("Node composition for %4.4x unknown\n" , dst);return false; }return true; } -static void cmd_bind (const char *args) +static void cmd_bind (int argc,char *argv[]) {uint16_t n;uint8_t msg[32 ];
@@ -493,9 +487,9 @@ static void cmd_bind(const char *args)if (!verify_config_target (target))return ; - parm_cnt =read_input_parameters (args); + parm_cnt =read_input_parameters (argc, argv);if (parm_cnt !=3 && parm_cnt !=4 ) { -rl_printf ("Bad arguments %s\n" , args); +bt_shell_printf ("Bad arguments\n" );return ; }
@@ -515,10 +509,10 @@ static void cmd_bind(const char *args) }if (!config_send (msg, n)) -rl_printf ("Failed to send \"MODEL APP BIND\"\n" ); +bt_shell_printf ("Failed to send \"MODEL APP BIND\"\n" ); } -static void cmd_set_ttl (const char *args) +static void cmd_set_ttl (int argc,char *argv[]) {uint16_t n;uint8_t msg[32 ];
@@ -526,13 +520,13 @@ static void cmd_set_ttl(const char *args)uint8_t ttl;if (IS_UNASSIGNED (target)) { -rl_printf ("Destination not set\n" ); +bt_shell_printf ("Destination not set\n" );return ; } n =mesh_opcode_set (OP_CONFIG_DEFAULT_TTL_SET , msg); - parm_cnt =read_input_parameters (args); + parm_cnt =read_input_parameters (argc, argv);if (parm_cnt) { ttl = parms[0 ] &TTL_MASK ; }else
@@ -541,10 +535,10 @@ static void cmd_set_ttl(const char *args) msg[n++] = ttl;if (!config_send (msg, n)) -rl_printf ("Failed to send \"SET_DEFAULT TTL\"\n" ); +bt_shell_printf ("Failed to send \"SET_DEFAULT TTL\"\n" ); } -static void cmd_set_pub (const char *args) +static void cmd_set_pub (int argc,char *argv[]) {uint16_t n;uint8_t msg[32 ];
@@ -555,9 +549,9 @@ static void cmd_set_pub(const char *args) n =mesh_opcode_set (OP_CONFIG_MODEL_PUB_SET , msg); - parm_cnt =read_input_parameters (args); + parm_cnt =read_input_parameters (argc, argv);if (parm_cnt !=5 ) { -rl_printf ("Bad arguments: %s\n" , args); +bt_shell_printf ("Bad arguments\n" );return ; }
@@ -586,7 +580,7 @@ static void cmd_set_pub(const char *args) }if (!config_send (msg, n)) -rl_printf ("Failed to send \"SET MODEL PUBLICATION\"\n" ); +bt_shell_printf ("Failed to send \"SET MODEL PUBLICATION\"\n" ); }static void cmd_default (uint32_t opcode)
@@ -595,29 +589,25 @@ static void cmd_default(uint32_t opcode)uint8_t msg[32 ];if (IS_UNASSIGNED (target)) { -rl_printf ("Destination not set\n" ); +bt_shell_printf ("Destination not set\n" );return ; } n =mesh_opcode_set (opcode, msg);if (!config_send (msg, n)) -rl_printf ("Failed to send command (opcode 0x%x)\n" , opcode); +bt_shell_printf ("Failed to send command (opcode 0x%x)\n" , + opcode); } -static void cmd_get_ttl (const char *args) +static void cmd_get_ttl (int argc,char *argv[]) {cmd_default (OP_CONFIG_DEFAULT_TTL_GET ); } -static void cmd_back (const char *args) -{ -cmd_menu_main (false); -} - -static void cmd_help (const char *args); - -static const struct menu_entry cfg_menu[] = { +static const struct bt_shell_menu cfg_menu = { + .name ="config" , + .entries = { {"target" ,"<unicast>" , cmd_set_node,"Set target node to configure" }, {"get-composition" ,"[<page_num>]" , cmd_get_composition,
@@ -639,30 +629,15 @@ static const struct menu_entry cfg_menu[] = { {"set-pub" ,"<ele_addr> <pub_addr> <app_idx> " "<period (step|res)> <model>" , cmd_set_pub, "Set publication"}, - {"back", NULL, cmd_back, - "Back to main menu"}, - {"help", NULL, cmd_help, - "Config Commands"}, - {} + {} }, }; -static void cmd_help (const char *args) -{ -rl_printf ("Client Configuration Menu\n" ); -print_cmd_menu (cfg_menu); -} - -void config_set_node (const char *args) -{ -cmd_set_node (args); -} -void config_client_get_composition (uint32_t dst) {uint32_t tmp = target; target = dst; -cmd_get_composition ("" ); +cmd_get_composition (0 ,NULL ); target = tmp; }
@@ -680,7 +655,7 @@ bool config_client_init(void) &client_cbs, NULL))return false; -add_cmd_menu ("configure" , cfg_menu); +bt_shell_add_submenu (&cfg_menu);return true; }
mesh/config-model.h +0 -1
@@ -99,4 +99,3 @@bool config_server_init (void );bool config_client_init (void );void config_client_get_composition (uint32_t dst); -void config_set_node (const char *args);
mesh/main.c +162 -409
1,254 lines not on this page · raw message
mesh/onoff-model.c +32 -56
206 lines not on this page · raw message
mesh/util.c +2 -153
173 lines not on this page · raw message
mesh/util.h +1 -15
@@ -27,21 +27,7 @@ struct mesh_publication;#define OP_UNRELIABLE 0x0100 -struct menu_entry { -const char *cmd; -const char *arg; -void (*func) (const char *arg); -const char *desc; -}; - -bool cmd_menu_init (const struct menu_entry *cmd_table); -void cmd_menu_main (bool forced); -bool add_cmd_menu (const char *name,const struct menu_entry *cmd_table); -bool switch_cmd_menu (const char *name); -void set_menu_prompt (const char *prefix,const char * node); -void process_menu_cmd (const char *cmd,const char *arg); -void print_cmd_menu (const struct menu_entry *cmd_table); -void cmd_menu_cleanup (void ); +void set_menu_prompt (const char *name,const char *id);void print_byte_array (const char *prefix,const void *ptr,int len);bool str2hex (const char *str,uint16_t in_len,uint8_t *out_buf,uint16_t out_len);
Signature · 1 line
2.13.6
Hi Luiz,
Quoted 37 lines
mesh/main.c +4
-5@@ -2177,7 +1949,6 @@ int main(int argc, char *argv[])GOptionContext *context;GError *error =NULL ;GDBusClient *client; -guint signal;int len;int extra;@@ -2196,22 +1967,22 @@ int main(int argc, char *argv[])g_option_context_free (context);if (option_version == TRUE) { -rl_printf ("%s\n" ,VERSION ); +bt_shell_printf ("%s\n" ,VERSION );exit (0 ); }if (!mesh_config_dir) { -rl_printf ("Local config directory not provided.\n" ); +bt_shell_printf ("Local config directory not provided.\n" ); mesh_config_dir ="" ; }else { -rl_printf ("Reading prov_db.json and local_node.json from %s\n" , +bt_shell_printf ("Reading prov_db.json and local_node.json from %s\n" , mesh_config_dir); } len =strlen (mesh_config_dir);if (len && mesh_config_dir[len -1 ] !='/' ) { extra =1 ; -rl_printf ("mesh_config_dir[%d] %s\n" , len, +bt_shell_printf ("mesh_config_dir[%d] %s\n" , len, &mesh_config_dir[len -1 ]); }else { extra =0 ;@@ -2257,18 +2028,11 @@ int main(int argc, char *argv[])exit (1 );
mesh/main.c int main(int argc, char *argv[]) · line 2031
Quoted 10 lines
mesh/main.c +1
-7} - main_loop =g_main_loop_new (NULL , FALSE); - dbus_conn =g_dbus_setup_bus (DBUS_BUS_SYSTEM ,NULL ,NULL ); - -setlinebuf (stdout); - - rl_erase_empty_line =1 ; -rl_callback_handler_install (NULL , rl_handler); +bt_shell_init (&argc, &argv);
meshctl will not output version with --version/-v.
Refer to the mail (shared/shell: Fix no version output with option) that I sent.
Regards,
Eramoto
Hi Luiz,
Quoted 10 lines · Luiz Augusto von Dentz
This makes meshctl use
bt_shellto manage the menus and command handling.--- mesh/config-client.c | 187 ++++++++--------- mesh/config-model.h | 1 - mesh/main.c | 571 +++++++++++++++------------------------------------ mesh/onoff-model.c | 88 +++----- mesh/util.c | 155 +------------- mesh/util.h | 16 +- 6 files changed, 278 insertions(+), 740 deletions(-)
There's still something broken. Did you test this at all?
If I issue "connect 1 2" right after starting meshctl I get this:
[meshctl]# connect 1 2
==16599== Invalid read of size 1
==16599== at 0x4C32B82: strlen (vg_replace_strmem.c:458) ==16599== by 0x4EA5962: g_strdup (in /usr/lib64/libglib-2.0.so.0.5400.2) ==16599== by 0x4EA7404: g_strdupv (in /usr/lib64/libglib-2.0.so.0.5400.2) ==16599== by 0x40861F: set_scan_filter_uuids.constprop.14 (main.c:1613) ==16599== by 0x4086E2: cmd_connect (main.c:1729) ==16599== by 0x41C8F7: cmd_exec (shell.c:290) ==16599== by 0x41C8F7: menu_exec (shell.c:314) ==16599== by 0x41D1B2: shell_exec (shell.c:326) ==16599== by 0x41D1B2: rl_handler (shell.c:473) ==16599== by 0x55DB8BD: rl_callback_read_char (in /usr/lib64/libreadline.so.7.0) ==16599== by 0x41C4E8: input_read (shell.c:765) ==16599== by 0x41D672: watch_callback (io-glib.c:170) ==16599== by 0x4E86BB6: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.5400.2) ==16599== by 0x4E86F5F: ??? (in /usr/lib64/libglib-2.0.so.0.5400.2)
==16599== Address 0x2 is not stack'd, malloc'd or (recently) free'd
It looks like the cause might be the new UUID string arrays which are expected to be NULL terminated.
Johan
Hi Luiz,
Quoted 32 lines · Johan Hedberg
Quoted 10 lines · Luiz Augusto von Dentz
This makes meshctl use
bt_shellto manage the menus and command handling.--- mesh/config-client.c | 187 ++++++++--------- mesh/config-model.h | 1 - mesh/main.c | 571 +++++++++++++++------------------------------------ mesh/onoff-model.c | 88 +++----- mesh/util.c | 155 +------------- mesh/util.h | 16 +- 6 files changed, 278 insertions(+), 740 deletions(-)There's still something broken. Did you test this at all?
If I issue "connect 1 2" right after starting meshctl I get this:
[meshctl]# connect 1 2
==16599== Invalid read of size 1==16599== at 0x4C32B82: strlen (vg_replace_strmem.c:458) ==16599== by 0x4EA5962: g_strdup (in /usr/lib64/libglib-2.0.so.0.5400.2) ==16599== by 0x4EA7404: g_strdupv (in /usr/lib64/libglib-2.0.so.0.5400.2) ==16599== by 0x40861F: set_scan_filter_uuids.constprop.14 (main.c:1613) ==16599== by 0x4086E2: cmd_connect (main.c:1729) ==16599== by 0x41C8F7: cmd_exec (shell.c:290) ==16599== by 0x41C8F7: menu_exec (shell.c:314) ==16599== by 0x41D1B2: shell_exec (shell.c:326) ==16599== by 0x41D1B2: rl_handler (shell.c:473) ==16599== by 0x55DB8BD: rl_callback_read_char (in /usr/lib64/libreadline.so.7.0) ==16599== by 0x41C4E8: input_read (shell.c:765) ==16599== by 0x41D672: watch_callback (io-glib.c:170) ==16599== by 0x4E86BB6: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.5400.2) ==16599== by 0x4E86F5F: ??? (in /usr/lib64/libglib-2.0.so.0.5400.2)
Quoted 4 lines
==16599== Address
0x2is not stack'd, malloc'd or (recently) free'dIt looks like the cause might be the new UUID string arrays which are expected to be NULL terminated.
Something like the attached patch seems to fix it.
Johan
mesh/main.c +3 -3
@@ -1625,7 +1625,7 @@ commit:static void cmd_scan_unprovisioned_devices (int argc,char *argv[]) {dbus_bool_t enable; -char *filters[] = {MESH_PROV_SVC_UUID }; +char *filters[2 ] = {MESH_PROV_SVC_UUID };if (parse_argument_on_off (argc, argv, &enable) == FALSE)return ;
@@ -1700,7 +1700,7 @@ static void cmd_security(int argc, char *argv[])static void cmd_connect (int argc,char *argv[]) { -char *filters[] = {MESH_PROXY_SVC_UUID }; +char *filters[2 ] = {MESH_PROXY_SVC_UUID };if (check_default_ctrl () == FALSE)return ;
@@ -1753,7 +1753,7 @@ static void cmd_connect(int argc, char *argv[])static void prov_disconn_reply (DBusMessage *message,void *user_data) {struct mesh_node *node = user_data; -char *filters[] = {MESH_PROXY_SVC_UUID }; +char *filters[2 ] = {MESH_PROXY_SVC_UUID };DBusError error;dbus_error_init (&error);