Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] core: replace sizeof(filename) with PATH_MAX
@ 2017-03-31 11:03 Konrad Zapalowicz
  2017-03-31 11:21 ` Bastien Nocera
  2017-03-31 14:44 ` [PATCH v2] " Konrad Zapalowicz
  0 siblings, 2 replies; 7+ messages in thread
From: Konrad Zapalowicz @ 2017-03-31 11:03 UTC (permalink / raw)
  To: marcel; +Cc: luiz.von.dentz, linux-bluetooth, Konrad Zapałowicz

From: Konrad Zapałowicz <konrad.zapalowicz@canonical.com>

This commit replaces sizeof(filename) with PATH_MAX to match the common
scheme which is used in other places.

Signed-off-by: Konrad Zapałowicz <konrad.zapalowicz@canonical.com>
---
 src/adapter.c     | 2 +-
 src/shared/util.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 3dac7d6..3935460 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -7107,7 +7107,7 @@ static void store_csrk(struct btd_adapter *adapter, const bdaddr_t *peer,
 
 	ba2str(peer, device_addr);
 
-	snprintf(filename, sizeof(filename), STORAGEDIR "/%s/%s/info",
+	snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info",
 					adapter_dir(adapter), device_addr);
 
 	key_file = g_key_file_new();
diff --git a/src/shared/util.c b/src/shared/util.c
index 7878552..4b59fad 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -117,7 +117,7 @@ unsigned char util_get_dt(const char *parent, const char *name)
 	char filename[PATH_MAX];
 	struct stat st;
 
-	snprintf(filename, sizeof(filename), "%s/%s", parent, name);
+	snprintf(filename, PATH_MAX, "%s/%s", parent, name);
 	if (lstat(filename, &st) == 0 && S_ISDIR(st.st_mode))
 		return DT_DIR;
 
-- 
2.7.4

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

* Re: [PATCH] core: replace sizeof(filename) with PATH_MAX
  2017-03-31 11:03 [PATCH] core: replace sizeof(filename) with PATH_MAX Konrad Zapalowicz
@ 2017-03-31 11:21 ` Bastien Nocera
  2017-03-31 11:32   ` Konrad Zapalowicz
  2017-03-31 14:44 ` [PATCH v2] " Konrad Zapalowicz
  1 sibling, 1 reply; 7+ messages in thread
From: Bastien Nocera @ 2017-03-31 11:21 UTC (permalink / raw)
  To: Konrad Zapalowicz, marcel; +Cc: luiz.von.dentz, linux-bluetooth

On Fri, 2017-03-31 at 13:03 +0200, Konrad Zapalowicz wrote:
> From: Konrad Zapałowicz <konrad.zapalowicz@canonical.com>
> 
> This commit replaces sizeof(filename) with PATH_MAX to match the
> common
> scheme which is used in other places.

I wonder why g_strdup_printf() isn't used instead. Would allow ignoring
PATH_MAX.

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

* Re: [PATCH] core: replace sizeof(filename) with PATH_MAX
  2017-03-31 11:21 ` Bastien Nocera
@ 2017-03-31 11:32   ` Konrad Zapalowicz
  2017-03-31 14:00     ` Von Dentz, Luiz
  0 siblings, 1 reply; 7+ messages in thread
From: Konrad Zapalowicz @ 2017-03-31 11:32 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: marcel, luiz.von.dentz, linux-bluetooth

On 03/31, Bastien Nocera wrote:
> On Fri, 2017-03-31 at 13:03 +0200, Konrad Zapalowicz wrote:
> > From: Konrad Zapałowicz <konrad.zapalowicz@canonical.com>
> > 
> > This commit replaces sizeof(filename) with PATH_MAX to match the
> > common
> > scheme which is used in other places.
> 
> I wonder why g_strdup_printf() isn't used instead. Would allow ignoring
> PATH_MAX.

I guess it is because it is easier. With g_strdup_printf() one would
have to take care about freeing memory. This is not a case with having
filename as an atomatic variable.

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

* Re: [PATCH] core: replace sizeof(filename) with PATH_MAX
  2017-03-31 11:32   ` Konrad Zapalowicz
@ 2017-03-31 14:00     ` Von Dentz, Luiz
  2017-03-31 14:15       ` Konrad Zapalowicz
  0 siblings, 1 reply; 7+ messages in thread
From: Von Dentz, Luiz @ 2017-03-31 14:00 UTC (permalink / raw)
  To: Konrad Zapalowicz
  Cc: Bastien Nocera, Marcel Holtmann, linux-bluetooth@vger.kernel.org

Hi Konrad,

On Fri, Mar 31, 2017 at 2:32 PM, Konrad Zapalowicz
<konrad.zapalowicz@canonical.com> wrote:
> On 03/31, Bastien Nocera wrote:
>> On Fri, 2017-03-31 at 13:03 +0200, Konrad Zapalowicz wrote:
>> > From: Konrad Zapa=C5=82owicz <konrad.zapalowicz@canonical.com>
>> >
>> > This commit replaces sizeof(filename) with PATH_MAX to match the
>> > common
>> > scheme which is used in other places.
>>
>> I wonder why g_strdup_printf() isn't used instead. Would allow ignoring
>> PATH_MAX.
>
> I guess it is because it is easier. With g_strdup_printf() one would
> have to take care about freeing memory. This is not a case with having
> filename as an atomatic variable.

Patch looks fine, but we don't use Signed-off-by in userspace tree.

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

* Re: [PATCH] core: replace sizeof(filename) with PATH_MAX
  2017-03-31 14:00     ` Von Dentz, Luiz
@ 2017-03-31 14:15       ` Konrad Zapalowicz
  0 siblings, 0 replies; 7+ messages in thread
From: Konrad Zapalowicz @ 2017-03-31 14:15 UTC (permalink / raw)
  To: Von Dentz, Luiz
  Cc: Bastien Nocera, Marcel Holtmann, linux-bluetooth@vger.kernel.org

On 03/31, Von Dentz, Luiz wrote:
> Hi Konrad,
> 
> On Fri, Mar 31, 2017 at 2:32 PM, Konrad Zapalowicz
> <konrad.zapalowicz@canonical.com> wrote:
> > On 03/31, Bastien Nocera wrote:
> >> On Fri, 2017-03-31 at 13:03 +0200, Konrad Zapalowicz wrote:
> >> > From: Konrad Zapałowicz <konrad.zapalowicz@canonical.com>
> >> >
> >> > This commit replaces sizeof(filename) with PATH_MAX to match the
> >> > common
> >> > scheme which is used in other places.
> >>
> >> I wonder why g_strdup_printf() isn't used instead. Would allow ignoring
> >> PATH_MAX.
> >
> > I guess it is because it is easier. With g_strdup_printf() one would
> > have to take care about freeing memory. This is not a case with having
> > filename as an atomatic variable.
> 
> Patch looks fine, but we don't use Signed-off-by in userspace tree

Ok, will resend.

Thanks,
K

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

* [PATCH v2] core: replace sizeof(filename) with PATH_MAX
  2017-03-31 11:03 [PATCH] core: replace sizeof(filename) with PATH_MAX Konrad Zapalowicz
  2017-03-31 11:21 ` Bastien Nocera
@ 2017-03-31 14:44 ` Konrad Zapalowicz
  2017-04-03 11:08   ` Luiz Augusto von Dentz
  1 sibling, 1 reply; 7+ messages in thread
From: Konrad Zapalowicz @ 2017-03-31 14:44 UTC (permalink / raw)
  To: marcel; +Cc: luiz.von.dentz, linux-bluetooth, Konrad Zapałowicz

From: Konrad Zapałowicz <konrad.zapalowicz@canonical.com>

This commit replaces sizeof(filename) with PATH_MAX to match the common
scheme which is used in other places.
---
 src/adapter.c     | 2 +-
 src/shared/util.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 3dac7d6..3935460 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -7107,7 +7107,7 @@ static void store_csrk(struct btd_adapter *adapter, const bdaddr_t *peer,
 
 	ba2str(peer, device_addr);
 
-	snprintf(filename, sizeof(filename), STORAGEDIR "/%s/%s/info",
+	snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info",
 					adapter_dir(adapter), device_addr);
 
 	key_file = g_key_file_new();
diff --git a/src/shared/util.c b/src/shared/util.c
index 7878552..4b59fad 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -117,7 +117,7 @@ unsigned char util_get_dt(const char *parent, const char *name)
 	char filename[PATH_MAX];
 	struct stat st;
 
-	snprintf(filename, sizeof(filename), "%s/%s", parent, name);
+	snprintf(filename, PATH_MAX, "%s/%s", parent, name);
 	if (lstat(filename, &st) == 0 && S_ISDIR(st.st_mode))
 		return DT_DIR;
 
-- 
2.7.4

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

* Re: [PATCH v2] core: replace sizeof(filename) with PATH_MAX
  2017-03-31 14:44 ` [PATCH v2] " Konrad Zapalowicz
@ 2017-04-03 11:08   ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 7+ messages in thread
From: Luiz Augusto von Dentz @ 2017-04-03 11:08 UTC (permalink / raw)
  To: Konrad Zapalowicz
  Cc: Marcel Holtmann, Luiz Augusto Von Dentz,
	linux-bluetooth@vger.kernel.org

Hi Konrad,

On Fri, Mar 31, 2017 at 5:44 PM, Konrad Zapalowicz
<konrad.zapalowicz@canonical.com> wrote:
> From: Konrad Zapa=C5=82owicz <konrad.zapalowicz@canonical.com>
>
> This commit replaces sizeof(filename) with PATH_MAX to match the common
> scheme which is used in other places.
> ---
>  src/adapter.c     | 2 +-
>  src/shared/util.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index 3dac7d6..3935460 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -7107,7 +7107,7 @@ static void store_csrk(struct btd_adapter *adapter,=
 const bdaddr_t *peer,
>
>         ba2str(peer, device_addr);
>
> -       snprintf(filename, sizeof(filename), STORAGEDIR "/%s/%s/info",
> +       snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info",
>                                         adapter_dir(adapter), device_addr=
);
>
>         key_file =3D g_key_file_new();
> diff --git a/src/shared/util.c b/src/shared/util.c
> index 7878552..4b59fad 100644
> --- a/src/shared/util.c
> +++ b/src/shared/util.c
> @@ -117,7 +117,7 @@ unsigned char util_get_dt(const char *parent, const c=
har *name)
>         char filename[PATH_MAX];
>         struct stat st;
>
> -       snprintf(filename, sizeof(filename), "%s/%s", parent, name);
> +       snprintf(filename, PATH_MAX, "%s/%s", parent, name);
>         if (lstat(filename, &st) =3D=3D 0 && S_ISDIR(st.st_mode))
>                 return DT_DIR;
>
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth=
" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Applied, thanks.

--=20
Luiz Augusto von Dentz

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

end of thread, other threads:[~2017-04-03 11:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-31 11:03 [PATCH] core: replace sizeof(filename) with PATH_MAX Konrad Zapalowicz
2017-03-31 11:21 ` Bastien Nocera
2017-03-31 11:32   ` Konrad Zapalowicz
2017-03-31 14:00     ` Von Dentz, Luiz
2017-03-31 14:15       ` Konrad Zapalowicz
2017-03-31 14:44 ` [PATCH v2] " Konrad Zapalowicz
2017-04-03 11:08   ` Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox