* [PATCH] Fix improper usage of g_free [not found] <CGME20180518034418epcas2p3b31813a79452e5934a438347b8edc82a@epcas2p3.samsung.com> @ 2018-05-18 3:44 ` Nagaraj D R 2018-05-21 8:37 ` Luiz Augusto von Dentz [not found] ` <CGME20180518034418epcas2p3b31813a79452e5934a438347b8edc82a@epcms5p2> 0 siblings, 2 replies; 5+ messages in thread From: Nagaraj D R @ 2018-05-18 3:44 UTC (permalink / raw) To: linux-bluetooth; +Cc: Syam Sidhardhan, Nagaraj D R g_free should be used for only those memory allocations done through glib APIs --- client/advertising.c | 2 +- src/adapter.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/advertising.c b/client/advertising.c index 045133a..5592be6 100644 --- a/client/advertising.c +++ b/client/advertising.c @@ -757,7 +757,7 @@ void ad_advertise_local_name(DBusConnection *conn, const char *name) return; g_free(ad.local_name); - ad.local_name = strdup(name); + ad.local_name = g_strdup(name); g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE, "LocalName"); diff --git a/src/adapter.c b/src/adapter.c index c1c792a..07a4e42 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -2258,7 +2258,7 @@ static bool parse_uuids(DBusMessageIter *value, struct discovery_filter *filter) bt_uuid_to_uuid128(&uuid, &u128); bt_uuid_to_string(&u128, uuidstr, sizeof(uuidstr)); - filter->uuids = g_slist_prepend(filter->uuids, strdup(uuidstr)); + filter->uuids = g_slist_prepend(filter->uuids, g_strdup(uuidstr)); dbus_message_iter_next(&arriter); } -- 1.9.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Fix improper usage of g_free 2018-05-18 3:44 ` [PATCH] Fix improper usage of g_free Nagaraj D R @ 2018-05-21 8:37 ` Luiz Augusto von Dentz [not found] ` <CGME20180518034418epcas2p3b31813a79452e5934a438347b8edc82a@epcms5p2> 1 sibling, 0 replies; 5+ messages in thread From: Luiz Augusto von Dentz @ 2018-05-21 8:37 UTC (permalink / raw) To: Nagaraj D R; +Cc: linux-bluetooth@vger.kernel.org, Syam Sidhardhan Hi, On Fri, May 18, 2018 at 6:44 AM, Nagaraj D R <nagaraj.dr@samsung.com> wrote: > g_free should be used for only those memory allocations > done through glib APIs > --- > client/advertising.c | 2 +- > src/adapter.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/client/advertising.c b/client/advertising.c > index 045133a..5592be6 100644 > --- a/client/advertising.c > +++ b/client/advertising.c > @@ -757,7 +757,7 @@ void ad_advertise_local_name(DBusConnection *conn, const char *name) > return; > > g_free(ad.local_name); > - ad.local_name = strdup(name); > + ad.local_name = g_strdup(name); > > g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE, "LocalName"); > > diff --git a/src/adapter.c b/src/adapter.c > index c1c792a..07a4e42 100644 > --- a/src/adapter.c > +++ b/src/adapter.c > @@ -2258,7 +2258,7 @@ static bool parse_uuids(DBusMessageIter *value, struct discovery_filter *filter) > bt_uuid_to_uuid128(&uuid, &u128); > bt_uuid_to_string(&u128, uuidstr, sizeof(uuidstr)); > > - filter->uuids = g_slist_prepend(filter->uuids, strdup(uuidstr)); > + filter->uuids = g_slist_prepend(filter->uuids, g_strdup(uuidstr)); > > dbus_message_iter_next(&arriter); > } > -- > 1.9.1 I rather not use the g_str* then, so we might need to replace g_free with free for local_name and also the filter. > -- > 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 -- Luiz Augusto von Dentz ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <CGME20180518034418epcas2p3b31813a79452e5934a438347b8edc82a@epcms5p2>]
* RE: Re: [PATCH] Fix improper usage of g_free [not found] ` <CGME20180518034418epcas2p3b31813a79452e5934a438347b8edc82a@epcms5p2> @ 2018-05-21 11:39 ` Nagaraj D R 2018-05-21 13:03 ` Luiz Augusto von Dentz 0 siblings, 1 reply; 5+ messages in thread From: Nagaraj D R @ 2018-05-21 11:39 UTC (permalink / raw) To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org, SYAM SIDHARDHAN Hi,=C2=A0=0D=0A=C2=A0=0D=0A>Hi,=0D=0A=C2=A0=0D=0A>On=C2=A0Fri,=C2=A0May=C2= =A018,=C2=A02018=C2=A0at=C2=A06:44=C2=A0AM,=C2=A0Nagaraj=C2=A0D=C2=A0R=C2= =A0<nagaraj.dr=40samsung.com>=C2=A0wrote:=0D=0A>>=C2=A0g_free=C2=A0should= =C2=A0be=C2=A0used=C2=A0for=C2=A0only=C2=A0those=C2=A0memory=C2=A0allocatio= ns=0D=0A>>=C2=A0done=C2=A0through=C2=A0glib=C2=A0APIs=0D=0A>>=C2=A0---=0D= =0A>>=C2=A0=C2=A0client/advertising.c=C2=A0=7C=C2=A02=C2=A0+-=0D=0A>>=C2=A0= =C2=A0src/adapter.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=7C=C2= =A02=C2=A0+-=0D=0A>>=C2=A0=C2=A02=C2=A0files=C2=A0changed,=C2=A02=C2=A0inse= rtions(+),=C2=A02=C2=A0deletions(-)=0D=0A>>=0D=0A>>=C2=A0diff=C2=A0--git=C2= =A0a/client/advertising.c=C2=A0b/client/advertising.c=0D=0A>>=C2=A0index=C2= =A0045133a..5592be6=C2=A0100644=0D=0A>>=C2=A0---=C2=A0a/client/advertising.= c=0D=0A>>=C2=A0+++=C2=A0b/client/advertising.c=0D=0A>>=C2=A0=40=40=C2=A0-75= 7,7=C2=A0+757,7=C2=A0=40=40=C2=A0void=C2=A0ad_advertise_local_name(DBusConn= ection=C2=A0*conn,=C2=A0const=C2=A0char=C2=A0*name)=0D=0A>>=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0return;=0D=0A>>=0D=0A>>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0g_free(ad.local_name);=0D=0A>>=C2=A0-=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0ad.local_name=C2=A0=3D=C2=A0strdup(name);=0D=0A>>=C2= =A0+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0ad.local_name=C2=A0=3D=C2=A0g= _strdup(name);=0D=0A>>=0D=0A>>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0g_dbus_emit_property_changed(conn,=C2=A0AD_PATH,=C2=A0AD_IFACE,=C2= =A0=22LocalName=22);=0D=0A>>=0D=0A>>=C2=A0diff=C2=A0--git=C2=A0a/src/adapte= r.c=C2=A0b/src/adapter.c=0D=0A>>=C2=A0index=C2=A0c1c792a..07a4e42=C2=A01006= 44=0D=0A>>=C2=A0---=C2=A0a/src/adapter.c=0D=0A>>=C2=A0+++=C2=A0b/src/adapte= r.c=0D=0A>>=C2=A0=40=40=C2=A0-2258,7=C2=A0+2258,7=C2=A0=40=40=C2=A0static= =C2=A0bool=C2=A0parse_uuids(DBusMessageIter=C2=A0*value,=C2=A0struct=C2=A0d= iscovery_filter=C2=A0*filter)=0D=0A>>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bt_uuid_t= o_uuid128(&uuid,=C2=A0&u128);=0D=0A>>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0bt_uuid_t= o_string(&u128,=C2=A0uuidstr,=C2=A0sizeof(uuidstr));=0D=0A>>=0D=0A>>=C2=A0-= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0filter->uuids=C2=A0=3D=C2=A0g_slist_prepend(filter->uuids,= =C2=A0strdup(uuidstr));=0D=0A>>=C2=A0+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0filter->uuids=C2=A0= =3D=C2=A0g_slist_prepend(filter->uuids,=C2=A0g_strdup(uuidstr));=0D=0A>>=0D= =0A>>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0dbus_message_iter_next(&arriter);=0D=0A>>= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=7D=0D=0A>>=C2=A0--= =0D=0A>>=C2=A01.9.1=0D=0A>I=C2=A0rather=C2=A0not=C2=A0use=C2=A0the=C2=A0g_s= tr*=C2=A0then,=C2=A0so=C2=A0we=C2=A0might=C2=A0need=C2=A0to=C2=A0replace=C2= =A0g_free=0D=0A>with=C2=A0free=C2=A0for=C2=A0local_name=C2=A0and=C2=A0also= =C2=A0the=C2=A0filter.=0D=0A=C2=A0=0D=0AI=20agree.=20I=20will=20send=20a=20= new=20patch ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Re: [PATCH] Fix improper usage of g_free 2018-05-21 11:39 ` Nagaraj D R @ 2018-05-21 13:03 ` Luiz Augusto von Dentz 0 siblings, 0 replies; 5+ messages in thread From: Luiz Augusto von Dentz @ 2018-05-21 13:03 UTC (permalink / raw) To: Nagaraj D R; +Cc: linux-bluetooth@vger.kernel.org, SYAM SIDHARDHAN Hi, On Mon, May 21, 2018 at 2:39 PM, Nagaraj D R <nagaraj.dr@samsung.com> wrote: > Hi, > >>Hi, > >>On Fri, May 18, 2018 at 6:44 AM, Nagaraj D R <nagaraj.dr@samsung.com> wrote: >>> g_free should be used for only those memory allocations >>> done through glib APIs >>> --- >>> client/advertising.c | 2 +- >>> src/adapter.c | 2 +- >>> 2 files changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/client/advertising.c b/client/advertising.c >>> index 045133a..5592be6 100644 >>> --- a/client/advertising.c >>> +++ b/client/advertising.c >>> @@ -757,7 +757,7 @@ void ad_advertise_local_name(DBusConnection *conn, const char *name) >>> return; >>> >>> g_free(ad.local_name); >>> - ad.local_name = strdup(name); >>> + ad.local_name = g_strdup(name); >>> >>> g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE, "LocalName"); >>> >>> diff --git a/src/adapter.c b/src/adapter.c >>> index c1c792a..07a4e42 100644 >>> --- a/src/adapter.c >>> +++ b/src/adapter.c >>> @@ -2258,7 +2258,7 @@ static bool parse_uuids(DBusMessageIter *value, struct discovery_filter *filter) >>> bt_uuid_to_uuid128(&uuid, &u128); >>> bt_uuid_to_string(&u128, uuidstr, sizeof(uuidstr)); >>> >>> - filter->uuids = g_slist_prepend(filter->uuids, strdup(uuidstr)); >>> + filter->uuids = g_slist_prepend(filter->uuids, g_strdup(uuidstr)); >>> >>> dbus_message_iter_next(&arriter); >>> } >>> -- >>> 1.9.1 >>I rather not use the g_str* then, so we might need to replace g_free >>with free for local_name and also the filter. > > I agree. I will send a new patch I actually fix this myself, but thanks for the feedback. -- Luiz Augusto von Dentz ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <CGME20180522032519epcas2p3cf940be103b17857bcb293a8bc37e5f8@epcas2p3.samsung.com>]
* [PATCH] Fix improper usage of g_free [not found] <CGME20180522032519epcas2p3cf940be103b17857bcb293a8bc37e5f8@epcas2p3.samsung.com> @ 2018-05-22 3:25 ` Nagaraj D R 0 siblings, 0 replies; 5+ messages in thread From: Nagaraj D R @ 2018-05-22 3:25 UTC (permalink / raw) To: linux-bluetooth; +Cc: Syam Sidhardhan, Nagaraj D R g_free should be used for only those memory allocations done through glib APIs This patch is in continuation with commit 01333078f591969f885bb94187a91d35e8fd5388 commit 8cfef5aa0c92c0ba096034fc1cd003a4f2c36bcf --- client/advertising.c | 2 +- src/adapter.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/advertising.c b/client/advertising.c index 39f9946..40fb3d5 100644 --- a/client/advertising.c +++ b/client/advertising.c @@ -756,7 +756,7 @@ void ad_advertise_local_name(DBusConnection *conn, const char *name) if (ad.local_name && !strcmp(name, ad.local_name)) return; - g_free(ad.local_name); + free(ad.local_name); ad.local_name = strdup(name); g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE, "LocalName"); diff --git a/src/adapter.c b/src/adapter.c index 390216a..9493587 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -2423,7 +2423,7 @@ static bool parse_discovery_filter_dict(struct btd_adapter *adapter, return true; invalid_args: - g_slist_free_full((*filter)->uuids, g_free); + g_slist_free_full((*filter)->uuids, free); g_free(*filter); *filter = NULL; return false; -- 1.9.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-05-22 3:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20180518034418epcas2p3b31813a79452e5934a438347b8edc82a@epcas2p3.samsung.com>
2018-05-18 3:44 ` [PATCH] Fix improper usage of g_free Nagaraj D R
2018-05-21 8:37 ` Luiz Augusto von Dentz
[not found] ` <CGME20180518034418epcas2p3b31813a79452e5934a438347b8edc82a@epcms5p2>
2018-05-21 11:39 ` Nagaraj D R
2018-05-21 13:03 ` Luiz Augusto von Dentz
[not found] <CGME20180522032519epcas2p3cf940be103b17857bcb293a8bc37e5f8@epcas2p3.samsung.com>
2018-05-22 3:25 ` Nagaraj D R
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).