2018-11-21 20:46:53

by Gix, Brian

[permalink] [raw]
Subject: [PATCH BlueZ] mesh: Up-rev ELL dependancies to >= 0.14

---
configure.ac | 4 ++--
mesh/dbus.c | 4 ++--
mesh/main.c | 27 ++++++++++-----------------
3 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/configure.ac b/configure.ac
index cbc854d62..d22f9d539 100644
--- a/configure.ac
+++ b/configure.ac
@@ -249,8 +249,8 @@ AC_ARG_ENABLE(btpclient, AC_HELP_STRING([--enable-btpclient],
AM_CONDITIONAL(BTPCLIENT, test "${enable_btpclient}" = "yes")

if (test "${enable_btpclient}" = "yes" || test "${enable_mesh}" = "yes"); then
- PKG_CHECK_MODULES(ELL, ell >= 0.3, enable_ell=yes,
- AC_MSG_ERROR(ell library >= 0.3 is required))
+ PKG_CHECK_MODULES(ELL, ell >= 0.14, enable_ell=yes,
+ AC_MSG_ERROR(ell library >= 0.14 is required))
AC_SUBST(ELL_CFLAGS)
AC_SUBST(ELL_LIBS)
fi
diff --git a/mesh/dbus.c b/mesh/dbus.c
index a94ba067d..0df664f2b 100644
--- a/mesh/dbus.c
+++ b/mesh/dbus.c
@@ -76,11 +76,11 @@ struct l_dbus_message *dbus_error(struct l_dbus_message *msg, int err,
if (description)
return l_dbus_message_new_error(msg,
error_table[err].dbus_err,
- description);
+ "%s", description);
else
return l_dbus_message_new_error(msg,
error_table[err].dbus_err,
- error_table[err].default_desc);
+ "%s", error_table[err].default_desc);
}

struct l_dbus *dbus_get_bus(void)
diff --git a/mesh/main.c b/mesh/main.c
index 0722f3af8..96a013510 100644
--- a/mesh/main.c
+++ b/mesh/main.c
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <unistd.h>
#include <ctype.h>
+#include <signal.h>

#include <sys/stat.h>
#include <ell/ell.h>
@@ -96,21 +97,16 @@ static void disconnect_callback(void *user_data)
l_main_quit();
}

-static void signal_handler(struct l_signal *signal, uint32_t signo,
- void *user_data)
+static void signal_handler(void *user_data)
{
static bool terminated;

- switch (signo) {
- case SIGINT:
- case SIGTERM:
- if (terminated)
- return;
- l_info("Terminating");
- l_main_quit();
- terminated = true;
- break;
- }
+ if (terminated)
+ return;
+
+ l_info("Terminating");
+ l_main_quit();
+ terminated = true;
}

int main(int argc, char *argv[])
@@ -120,7 +116,6 @@ int main(int argc, char *argv[])
bool dbus_debug = false;
struct l_dbus *dbus = NULL;
struct l_signal *signal = NULL;
- sigset_t mask;
const char *config_dir = NULL;
int index = MGMT_INDEX_NONE;

@@ -181,10 +176,8 @@ int main(int argc, char *argv[])
goto done;
}

- sigemptyset(&mask);
- sigaddset(&mask, SIGINT);
- sigaddset(&mask, SIGTERM);
- signal = l_signal_create(&mask, signal_handler, NULL, NULL);
+ signal = l_signal_create(SIGINT, signal_handler, NULL, NULL);
+ signal = l_signal_create(SIGTERM, signal_handler, NULL, NULL);

umask(0077);

--
2.14.5



2018-11-22 07:13:54

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH BlueZ] mesh: Up-rev ELL dependancies to >= 0.14

Hi Brian,

> ---
> configure.ac | 4 ++--
> mesh/dbus.c | 4 ++--
> mesh/main.c | 27 ++++++++++-----------------
> 3 files changed, 14 insertions(+), 21 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index cbc854d62..d22f9d539 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -249,8 +249,8 @@ AC_ARG_ENABLE(btpclient, AC_HELP_STRING([--enable-btpclient],
> AM_CONDITIONAL(BTPCLIENT, test "${enable_btpclient}" = "yes")
>
> if (test "${enable_btpclient}" = "yes" || test "${enable_mesh}" = "yes"); then
> - PKG_CHECK_MODULES(ELL, ell >= 0.3, enable_ell=yes,
> - AC_MSG_ERROR(ell library >= 0.3 is required))
> + PKG_CHECK_MODULES(ELL, ell >= 0.14, enable_ell=yes,
> + AC_MSG_ERROR(ell library >= 0.14 is required))
> AC_SUBST(ELL_CFLAGS)
> AC_SUBST(ELL_LIBS)
> fi
> diff --git a/mesh/dbus.c b/mesh/dbus.c
> index a94ba067d..0df664f2b 100644
> --- a/mesh/dbus.c
> +++ b/mesh/dbus.c
> @@ -76,11 +76,11 @@ struct l_dbus_message *dbus_error(struct l_dbus_message *msg, int err,
> if (description)
> return l_dbus_message_new_error(msg,
> error_table[err].dbus_err,
> - description);
> + "%s", description);
> else
> return l_dbus_message_new_error(msg,
> error_table[err].dbus_err,
> - error_table[err].default_desc);
> + "%s", error_table[err].default_desc);
> }
>
> struct l_dbus *dbus_get_bus(void)
> diff --git a/mesh/main.c b/mesh/main.c
> index 0722f3af8..96a013510 100644
> --- a/mesh/main.c
> +++ b/mesh/main.c
> @@ -26,6 +26,7 @@
> #include <stdio.h>
> #include <unistd.h>
> #include <ctype.h>
> +#include <signal.h>
>
> #include <sys/stat.h>
> #include <ell/ell.h>
> @@ -96,21 +97,16 @@ static void disconnect_callback(void *user_data)
> l_main_quit();
> }
>
> -static void signal_handler(struct l_signal *signal, uint32_t signo,
> - void *user_data)
> +static void signal_handler(void *user_data)
> {
> static bool terminated;
>
> - switch (signo) {
> - case SIGINT:
> - case SIGTERM:
> - if (terminated)
> - return;
> - l_info("Terminating");
> - l_main_quit();
> - terminated = true;
> - break;
> - }
> + if (terminated)
> + return;
> +
> + l_info("Terminating");
> + l_main_quit();
> + terminated = true;
> }
>
> int main(int argc, char *argv[])
> @@ -120,7 +116,6 @@ int main(int argc, char *argv[])
> bool dbus_debug = false;
> struct l_dbus *dbus = NULL;
> struct l_signal *signal = NULL;
> - sigset_t mask;
> const char *config_dir = NULL;
> int index = MGMT_INDEX_NONE;
>
> @@ -181,10 +176,8 @@ int main(int argc, char *argv[])
> goto done;
> }
>
> - sigemptyset(&mask);
> - sigaddset(&mask, SIGINT);
> - sigaddset(&mask, SIGTERM);
> - signal = l_signal_create(&mask, signal_handler, NULL, NULL);
> + signal = l_signal_create(SIGINT, signal_handler, NULL, NULL);
> + signal = l_signal_create(SIGTERM, signal_handler, NULL, NULL);

why not switch to l_main_run_with_signal() instead. We will be hiding the whole signal handling eventually anyway.

Regards

Marcel


2018-11-22 08:20:02

by Szymon Janc

[permalink] [raw]
Subject: Re: [PATCH BlueZ] mesh: Up-rev ELL dependancies to >= 0.14

Hi Brian,

On Wednesday, 21 November 2018 21:46:41 CET Brian Gix wrote:
> ---
> configure.ac | 4 ++--
> mesh/dbus.c | 4 ++--
> mesh/main.c | 27 ++++++++++-----------------
> 3 files changed, 14 insertions(+), 21 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index cbc854d62..d22f9d539 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -249,8 +249,8 @@ AC_ARG_ENABLE(btpclient,
> AC_HELP_STRING([--enable-btpclient], AM_CONDITIONAL(BTPCLIENT, test
> "${enable_btpclient}" = "yes")
>
> if (test "${enable_btpclient}" = "yes" || test "${enable_mesh}" = "yes");
> then - PKG_CHECK_MODULES(ELL, ell >= 0.3, enable_ell=yes,
> - AC_MSG_ERROR(ell library >= 0.3 is required))
> + PKG_CHECK_MODULES(ELL, ell >= 0.14, enable_ell=yes,
> + AC_MSG_ERROR(ell library >= 0.14 is required))
> AC_SUBST(ELL_CFLAGS)
> AC_SUBST(ELL_LIBS)
> fi
> diff --git a/mesh/dbus.c b/mesh/dbus.c
> index a94ba067d..0df664f2b 100644
> --- a/mesh/dbus.c
> +++ b/mesh/dbus.c
> @@ -76,11 +76,11 @@ struct l_dbus_message *dbus_error(struct l_dbus_message
> *msg, int err, if (description)
> return l_dbus_message_new_error(msg,
> error_table[err].dbus_err,
> - description);
> + "%s", description);
> else
> return l_dbus_message_new_error(msg,
> error_table[err].dbus_err,
> - error_table[err].default_desc);
> + "%s", error_table[err].default_desc);
> }
>
> struct l_dbus *dbus_get_bus(void)
> diff --git a/mesh/main.c b/mesh/main.c
> index 0722f3af8..96a013510 100644
> --- a/mesh/main.c
> +++ b/mesh/main.c
> @@ -26,6 +26,7 @@
> #include <stdio.h>
> #include <unistd.h>
> #include <ctype.h>
> +#include <signal.h>
>
> #include <sys/stat.h>
> #include <ell/ell.h>
> @@ -96,21 +97,16 @@ static void disconnect_callback(void *user_data)
> l_main_quit();
> }
>
> -static void signal_handler(struct l_signal *signal, uint32_t signo,
> - void *user_data)
> +static void signal_handler(void *user_data)
> {
> static bool terminated;
>
> - switch (signo) {
> - case SIGINT:
> - case SIGTERM:
> - if (terminated)
> - return;
> - l_info("Terminating");
> - l_main_quit();
> - terminated = true;
> - break;
> - }
> + if (terminated)
> + return;
> +
> + l_info("Terminating");
> + l_main_quit();
> + terminated = true;
> }
>
> int main(int argc, char *argv[])
> @@ -120,7 +116,6 @@ int main(int argc, char *argv[])
> bool dbus_debug = false;
> struct l_dbus *dbus = NULL;
> struct l_signal *signal = NULL;
> - sigset_t mask;
> const char *config_dir = NULL;
> int index = MGMT_INDEX_NONE;
>
> @@ -181,10 +176,8 @@ int main(int argc, char *argv[])
> goto done;
> }
>
> - sigemptyset(&mask);
> - sigaddset(&mask, SIGINT);
> - sigaddset(&mask, SIGTERM);
> - signal = l_signal_create(&mask, signal_handler, NULL, NULL);
> + signal = l_signal_create(SIGINT, signal_handler, NULL, NULL);
> + signal = l_signal_create(SIGTERM, signal_handler, NULL, NULL);
>
> umask(0077);

btpclient is also using ELL, should it be updated too?

--
pozdrawiam
Szymon Janc



2018-11-22 09:27:58

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH BlueZ] mesh: Up-rev ELL dependancies to >= 0.14

Hi Szymon,

>> ---
>> configure.ac | 4 ++--
>> mesh/dbus.c | 4 ++--
>> mesh/main.c | 27 ++++++++++-----------------
>> 3 files changed, 14 insertions(+), 21 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index cbc854d62..d22f9d539 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -249,8 +249,8 @@ AC_ARG_ENABLE(btpclient,
>> AC_HELP_STRING([--enable-btpclient], AM_CONDITIONAL(BTPCLIENT, test
>> "${enable_btpclient}" = "yes")
>>
>> if (test "${enable_btpclient}" = "yes" || test "${enable_mesh}" = "yes");
>> then - PKG_CHECK_MODULES(ELL, ell >= 0.3, enable_ell=yes,
>> - AC_MSG_ERROR(ell library >= 0.3 is required))
>> + PKG_CHECK_MODULES(ELL, ell >= 0.14, enable_ell=yes,
>> + AC_MSG_ERROR(ell library >= 0.14 is required))
>> AC_SUBST(ELL_CFLAGS)
>> AC_SUBST(ELL_LIBS)
>> fi
>> diff --git a/mesh/dbus.c b/mesh/dbus.c
>> index a94ba067d..0df664f2b 100644
>> --- a/mesh/dbus.c
>> +++ b/mesh/dbus.c
>> @@ -76,11 +76,11 @@ struct l_dbus_message *dbus_error(struct l_dbus_message
>> *msg, int err, if (description)
>> return l_dbus_message_new_error(msg,
>> error_table[err].dbus_err,
>> - description);
>> + "%s", description);
>> else
>> return l_dbus_message_new_error(msg,
>> error_table[err].dbus_err,
>> - error_table[err].default_desc);
>> + "%s", error_table[err].default_desc);
>> }
>>
>> struct l_dbus *dbus_get_bus(void)
>> diff --git a/mesh/main.c b/mesh/main.c
>> index 0722f3af8..96a013510 100644
>> --- a/mesh/main.c
>> +++ b/mesh/main.c
>> @@ -26,6 +26,7 @@
>> #include <stdio.h>
>> #include <unistd.h>
>> #include <ctype.h>
>> +#include <signal.h>
>>
>> #include <sys/stat.h>
>> #include <ell/ell.h>
>> @@ -96,21 +97,16 @@ static void disconnect_callback(void *user_data)
>> l_main_quit();
>> }
>>
>> -static void signal_handler(struct l_signal *signal, uint32_t signo,
>> - void *user_data)
>> +static void signal_handler(void *user_data)
>> {
>> static bool terminated;
>>
>> - switch (signo) {
>> - case SIGINT:
>> - case SIGTERM:
>> - if (terminated)
>> - return;
>> - l_info("Terminating");
>> - l_main_quit();
>> - terminated = true;
>> - break;
>> - }
>> + if (terminated)
>> + return;
>> +
>> + l_info("Terminating");
>> + l_main_quit();
>> + terminated = true;
>> }
>>
>> int main(int argc, char *argv[])
>> @@ -120,7 +116,6 @@ int main(int argc, char *argv[])
>> bool dbus_debug = false;
>> struct l_dbus *dbus = NULL;
>> struct l_signal *signal = NULL;
>> - sigset_t mask;
>> const char *config_dir = NULL;
>> int index = MGMT_INDEX_NONE;
>>
>> @@ -181,10 +176,8 @@ int main(int argc, char *argv[])
>> goto done;
>> }
>>
>> - sigemptyset(&mask);
>> - sigaddset(&mask, SIGINT);
>> - sigaddset(&mask, SIGTERM);
>> - signal = l_signal_create(&mask, signal_handler, NULL, NULL);
>> + signal = l_signal_create(SIGINT, signal_handler, NULL, NULL);
>> + signal = l_signal_create(SIGTERM, signal_handler, NULL, NULL);
>>
>> umask(0077);
>
> btpclient is also using ELL, should it be updated too?

yes, please.

Regards

Marcel