All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ] tools/meshctl: Fix default directory for JSON files
@ 2018-08-19 21:30 Inga Stotland
  2018-08-20  8:01 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 3+ messages in thread
From: Inga Stotland @ 2018-08-19 21:30 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Inga Stotland

This fixes the name of default directory that contains sample JSON files.
---
 tools/meshctl.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/tools/meshctl.c b/tools/meshctl.c
index 3e1484f61..a8468b716 100644
--- a/tools/meshctl.c
+++ b/tools/meshctl.c
@@ -1913,21 +1913,20 @@ int main(int argc, char *argv[])
 	bt_shell_set_prompt(PROMPT_OFF);
 
 	if (!mesh_config_dir) {
-		bt_shell_printf("Local config directory not provided.\n");
-		mesh_config_dir = "";
-	} else {
-		bt_shell_printf("Reading prov_db.json and local_node.json from"
-				" %s\n", mesh_config_dir);
+		printf("Local config directory not provided.\n");
+		mesh_config_dir = "mesh";
 	}
 
+	printf("Reading prov_db.json and local_node.json from"
+				" %s directory\n", mesh_config_dir);
+
 	len = strlen(mesh_config_dir);
-	if (len && mesh_config_dir[len - 1] != '/') {
+
+	if (len && mesh_config_dir[len - 1] != '/')
 		extra = 1;
-		bt_shell_printf("mesh_config_dir[%d] %s\n", len,
-						&mesh_config_dir[len - 1]);
-	} else {
+	else
 		extra = 0;
-	}
+
 	mesh_local_config_filename = g_malloc(len + strlen("local_node.json")
 									+ 2);
 	if (!mesh_local_config_filename)
@@ -1956,6 +1955,7 @@ int main(int argc, char *argv[])
 
 	sprintf(mesh_prov_db_filename, "%s", mesh_config_dir);
 	len = strlen(mesh_config_dir);
+
 	if (extra)
 		sprintf(mesh_prov_db_filename + len , "%c", '/');
 
-- 
2.14.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH BlueZ] tools/meshctl: Fix default directory for JSON files
  2018-08-19 21:30 [PATCH BlueZ] tools/meshctl: Fix default directory for JSON files Inga Stotland
@ 2018-08-20  8:01 ` Luiz Augusto von Dentz
  2018-08-21  6:28   ` Stotland, Inga
  0 siblings, 1 reply; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2018-08-20  8:01 UTC (permalink / raw)
  To: Inga Stotland; +Cc: linux-bluetooth

Hi Inga,

On Mon, Aug 20, 2018 at 12:30 AM, Inga Stotland <inga.stotland@intel.com> wrote:
> This fixes the name of default directory that contains sample JSON files.

Just a note regarding modifying/using files on the tree, as we
experience here it is a bad idea since once we move or it is changed
this code would have to be changed as well. Also I remember commenting
that if the configuration is changed by meshctl your tree will then
contain changes that shall not be applied, so instead of changing the
file in place Id make a default location something like
~/.config/meshctl/ and copy over the .json files there if they don't
exist, that way we avoid having to carry changes in the tree.

> ---
>  tools/meshctl.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/tools/meshctl.c b/tools/meshctl.c
> index 3e1484f61..a8468b716 100644
> --- a/tools/meshctl.c
> +++ b/tools/meshctl.c
> @@ -1913,21 +1913,20 @@ int main(int argc, char *argv[])
>         bt_shell_set_prompt(PROMPT_OFF);
>
>         if (!mesh_config_dir) {
> -               bt_shell_printf("Local config directory not provided.\n");
> -               mesh_config_dir = "";
> -       } else {
> -               bt_shell_printf("Reading prov_db.json and local_node.json from"
> -                               " %s\n", mesh_config_dir);
> +               printf("Local config directory not provided.\n");
> +               mesh_config_dir = "mesh";
>         }
>
> +       printf("Reading prov_db.json and local_node.json from"
> +                               " %s directory\n", mesh_config_dir);
> +
>         len = strlen(mesh_config_dir);
> -       if (len && mesh_config_dir[len - 1] != '/') {
> +
> +       if (len && mesh_config_dir[len - 1] != '/')
>                 extra = 1;
> -               bt_shell_printf("mesh_config_dir[%d] %s\n", len,
> -                                               &mesh_config_dir[len - 1]);
> -       } else {
> +       else
>                 extra = 0;
> -       }
> +
>         mesh_local_config_filename = g_malloc(len + strlen("local_node.json")
>                                                                         + 2);
>         if (!mesh_local_config_filename)
> @@ -1956,6 +1955,7 @@ int main(int argc, char *argv[])
>
>         sprintf(mesh_prov_db_filename, "%s", mesh_config_dir);
>         len = strlen(mesh_config_dir);
> +
>         if (extra)
>                 sprintf(mesh_prov_db_filename + len , "%c", '/');
>
> --
> 2.14.4
>



-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH BlueZ] tools/meshctl: Fix default directory for JSON files
  2018-08-20  8:01 ` Luiz Augusto von Dentz
@ 2018-08-21  6:28   ` Stotland, Inga
  0 siblings, 0 replies; 3+ messages in thread
From: Stotland, Inga @ 2018-08-21  6:28 UTC (permalink / raw)
  To: luiz.dentz; +Cc: linux-bluetooth

SGkgTHVpeiwNCg0KT24gTW9uLCAyMDE4LTA4LTIwIGF0IDExOjAxICswMzAwLCBMdWl6IEF1Z3Vz
dG8gdm9uIERlbnR6IHdyb3RlOg0KPiBIaSBJbmdhLA0KPiANCj4gT24gTW9uLCBBdWcgMjAsIDIw
MTggYXQgMTI6MzAgQU0sIEluZ2EgU3RvdGxhbmQgPGluZ2Euc3RvdGxhbmRAaW50ZWwuDQo+IGNv
bT4gd3JvdGU6DQo+ID4gVGhpcyBmaXhlcyB0aGUgbmFtZSBvZiBkZWZhdWx0IGRpcmVjdG9yeSB0
aGF0IGNvbnRhaW5zIHNhbXBsZSBKU09ODQo+ID4gZmlsZXMuDQo+IA0KPiBKdXN0IGEgbm90ZSBy
ZWdhcmRpbmcgbW9kaWZ5aW5nL3VzaW5nIGZpbGVzIG9uIHRoZSB0cmVlLCBhcyB3ZQ0KPiBleHBl
cmllbmNlIGhlcmUgaXQgaXMgYSBiYWQgaWRlYSBzaW5jZSBvbmNlIHdlIG1vdmUgb3IgaXQgaXMg
Y2hhbmdlZA0KPiB0aGlzIGNvZGUgd291bGQgaGF2ZSB0byBiZSBjaGFuZ2VkIGFzIHdlbGwuIEFs
c28gSSByZW1lbWJlcg0KPiBjb21tZW50aW5nDQo+IHRoYXQg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wgY29uZmlnIGRpcmVjdG9yeSBub3QNCj4g
PiBwcm92aWRlZC5cbiIpOw0KPiA+IC0gICAgICAgICAgICAgICBtZXNoX2NvbmZpZ19kaXIgPSAi
IjsNCj4gPiAtICAgICAgIH0gZWxzZSB7DQo+ID4gLSAgICAgICAgICAgICAgIGJ0X3NoZWxsX3By
aW50ZigiUmVhZGluZyBwcm92X2RiLmpzb24gYW5kDQo+ID4gbG9jYWxfbm9kZS5qc29uIGZyb20i
DQo+ID4gLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiICVzXG4iLCBtZXNoX2NvbmZp
Z19kaXIpOw0KPiA+ICsgICAgICAgICAgICAgICBwcmludGYoIkxvY2FsIGNvbmZpZyBkaXJlY3Rv
cnkgbm90IHByb3ZpZGVkLlxuIik7DQo+ID4gKyAgICAgICAgICAgICAgIG1lc2hfY29uZmlnX2Rp
ciA9ICJtZXNoIjsNCj4gPiAgICAgICAgIH0NCj4gPiANCj4gPiArICAgICAgIHByaW50ZigiUmVh
ZGluZyBwcm92X2RiLmpzb24gYW5kIGxvY2FsX25vZGUuanNvbiBmcm9tIg0KPiA+ICsgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgIiAlcyBkaXJlY3RvcnlcbiIsDQo+ID4gbWVzaF9jb25m
aWdfZGlyKTsNCj4gPiArDQo+ID4gICAgICAgICBsZW4gPSBzdHJsZW4obWVzaF9jb25maWdfZGly
KTsNCj4gPiAtICAgICAgIGlmIChsZW4gJiYgbWVzaF9jb25maWdfZGlyW2xlbiAtIDFdICE9ICcv
Jykgew0KPiA+ICsNCj4gPiArICAgICAgIGlmIChsZW4gJiYgbWVzaF9jb25maWdfZGlyW2xlbiAt
IDFdICE9ICcvJykNCj4gPiAgICAgICAgICAgICAgICAgZXh0cmEgPSAxOw0KPiA+IC0gICAgICAg
ICAgICAgICBidF9zaGVsbF9wcmludGYoIm1lc2hfY29uZmlnX2RpclslZF0gJXNcbiIsIGxlbiwN
Cj4gPiAtICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAmbWVz
aF9jb25maWdfZGlyW2xlDQo+ID4gbiAtIDFdKTsNCj4gPiAtICAgICAgIH0gZWxzZSB7DQo+ID4g
KyAgICAgICBlbHNlDQo+ID4gICAgICAgICAgICAgICAgIGV4dHJhID0gMDsNCj4gPiAtICAgICAg
IH0NCj4gPiArDQo+ID4gICAgICAgICBtZXNoX2xvY2FsX2NvbmZpZ19maWxlbmFtZSA9IGdfbWFs
bG9jKGxlbiArDQo+ID4gc3RybGVuKCJsb2NhbF9ub2RlLmpzb24iKQ0KPiA+ICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAN
Cj4gPiAgICAgICsgMik7DQo+ID4gICAgICAgICBpZiAoIW1lc2hfbG9jYWxfY29uZmlnX2ZpbGVu
YW1lKQ0KPiA+IEBAIC0xOTU2LDYgKzE5NTUsNyBAQCBpbnQgbWFpbihpbnQgYXJnYywgY2hhciAq
YXJndltdKQ0KPiA+IA0KPiA+ICAgICAgICAgc3ByaW50ZihtZXNoX3Byb3ZfZGJfZmlsZW5hbWUs
ICIlcyIsIG1lc2hfY29uZmlnX2Rpcik7DQo+ID4gICAgICAgICBsZW4gPSBzdHJsZW4obWVzaF9j
b25maWdfZGlyKTsNCj4gPiArDQo+ID4gICAgICAgICBpZiAoZXh0cmEpDQo+ID4gICAgICAgICAg
ICAgICAgIHNwcmludGYobWVzaF9wcm92X2RiX2ZpbGVuYW1lICsgbGVuICwgIiVjIiwgJy8nKTsN
Cj4gPiANCj4gPiAtLQ0KPiA+IDIuMTQuNA0KPiA+IA0KDQpUaGFua3MgZm9yIHRoZSBmZWVkYmFj
ay4gSSBhZ3JlZS4NClNlbnQgcGF0Y2ggc2V0IHYyLg0KDQpSZWdhcmRzLA0KSW5nYQ==

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-21  6:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-19 21:30 [PATCH BlueZ] tools/meshctl: Fix default directory for JSON files Inga Stotland
2018-08-20  8:01 ` Luiz Augusto von Dentz
2018-08-21  6:28   ` Stotland, Inga

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.