Re: [E-devel] [EGIT] [core/efl] master 02/02: ecore_con, elput: fix warnings

2016-09-21 Thread Gustavo Sverzut Barbieri
On Wed, Sep 21, 2016 at 8:35 PM, Carsten Haitzler  wrote:
> On Tue, 20 Sep 2016 23:21:55 -0300 Gustavo Sverzut Barbieri
>  said:
>
>> On Tue, Sep 20, 2016 at 8:26 PM, Bruno Dilly  wrote:
>> > cedric pushed a commit to branch master.
>> >
>> > http://git.enlightenment.org/core/efl.git/commit/?id=a3fba57b2616f78fbdab7b43ac8e8aea7c56475b
>> >
>> > commit a3fba57b2616f78fbdab7b43ac8e8aea7c56475b
>> > Author: Bruno Dilly 
>> > Date:   Tue Sep 20 16:13:25 2016 -0700
>> >
>> > ecore_con,elput: fix warnings
>> >
>> > Summary:
>> > elput: fix warning for unused write result
>> >  ecore_con: fix warning for unused asprintf result
>> >
>> > Reviewers: iscaro, devilhorns, cedric
>> >
>> > Reviewed By: cedric
>> >
>> > Subscribers: cedric, seoz, jpeg
>> >
>> > Differential Revision: https://phab.enlightenment.org/D4308
>> >
>> > Signed-off-by: Cedric BAIL 
>> > ---
>> >  src/lib/ecore_con/ecore_con.c | 15 +++
>> >  src/lib/elput/elput_logind.c  | 14 +-
>> >  2 files changed, 24 insertions(+), 5 deletions(-)
>> >
>> > diff --git a/src/lib/ecore_con/ecore_con.c b/src/lib/ecore_con/ecore_con.c
>> > index cc17fe8..cb66b27 100644
>> > --- a/src/lib/ecore_con/ecore_con.c
>> > +++ b/src/lib/ecore_con/ecore_con.c
>> > @@ -4487,11 +4487,18 @@ _efl_net_ip_connect_async_run(void *data,
>> > Ecore_Thread *thread EINA_UNUSED)
>> >   * parameter must be a URL with schema, otherwise it won't
>> >   * return anything.
>> >   */
>> > -char *url;
>> > +Eina_Stringshare *url;
>> >
>> > -asprintf(&url, "%s://%s:%s", d->protocol == IPPROTO_UDP ? "udp" :
>> > "tcp", host, port);
>> > -proxies = ecore_con_libproxy_proxies_get(url);
>> > -free(url);
>> > +url = eina_stringshare_printf("%s://%s:%s", d->protocol ==
>> > IPPROTO_UDP ? "udp" : "tcp", host, port);
>> > +if (!url)
>> > +  {
>> > + ERR("Could not assemble URL");
>> > +  }
>> > +else
>> > +  {
>> > + proxies = ecore_con_libproxy_proxies_get(url);
>> > + eina_stringshare_del(url);
>> > +  }
>>
>> why are you using stringshare here?
>>
>>  - this is used only once, share makes no benefit.
>>
>>  - this is used from thread, not sure eina stringshare is thread safe.
>>
>> if it's complaining about asprintf() on some weirdo platform, we can
>> malloc + memcpy the pieces
>
> last i knew asnprintf is "not portable" like strdupa. alloca is about the only
> thing we can trust to work. :)

asprintf() is simple:

static inline int asprintf(...) {
int len = snprintf("", 0, ...);
char *buf = malloc(len + 1);
snprintf(buf, len + 1, ...);
}

strdupa is not listed above, but also implementable as a macro:

#define strdupa(str) ({char *__buf = alloca(strlen(str) + 1);
memcpy(__buf, str, strlen(str) + 1); buf})





-- 
Gustavo Sverzut Barbieri
--
Mobile: +55 (16) 99354-9890

--
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [EGIT] [core/efl] master 02/02: ecore_con, elput: fix warnings

2016-09-21 Thread The Rasterman
On Tue, 20 Sep 2016 23:21:55 -0300 Gustavo Sverzut Barbieri
 said:

> On Tue, Sep 20, 2016 at 8:26 PM, Bruno Dilly  wrote:
> > cedric pushed a commit to branch master.
> >
> > http://git.enlightenment.org/core/efl.git/commit/?id=a3fba57b2616f78fbdab7b43ac8e8aea7c56475b
> >
> > commit a3fba57b2616f78fbdab7b43ac8e8aea7c56475b
> > Author: Bruno Dilly 
> > Date:   Tue Sep 20 16:13:25 2016 -0700
> >
> > ecore_con,elput: fix warnings
> >
> > Summary:
> > elput: fix warning for unused write result
> >  ecore_con: fix warning for unused asprintf result
> >
> > Reviewers: iscaro, devilhorns, cedric
> >
> > Reviewed By: cedric
> >
> > Subscribers: cedric, seoz, jpeg
> >
> > Differential Revision: https://phab.enlightenment.org/D4308
> >
> > Signed-off-by: Cedric BAIL 
> > ---
> >  src/lib/ecore_con/ecore_con.c | 15 +++
> >  src/lib/elput/elput_logind.c  | 14 +-
> >  2 files changed, 24 insertions(+), 5 deletions(-)
> >
> > diff --git a/src/lib/ecore_con/ecore_con.c b/src/lib/ecore_con/ecore_con.c
> > index cc17fe8..cb66b27 100644
> > --- a/src/lib/ecore_con/ecore_con.c
> > +++ b/src/lib/ecore_con/ecore_con.c
> > @@ -4487,11 +4487,18 @@ _efl_net_ip_connect_async_run(void *data,
> > Ecore_Thread *thread EINA_UNUSED)
> >   * parameter must be a URL with schema, otherwise it won't
> >   * return anything.
> >   */
> > -char *url;
> > +Eina_Stringshare *url;
> >
> > -asprintf(&url, "%s://%s:%s", d->protocol == IPPROTO_UDP ? "udp" :
> > "tcp", host, port);
> > -proxies = ecore_con_libproxy_proxies_get(url);
> > -free(url);
> > +url = eina_stringshare_printf("%s://%s:%s", d->protocol ==
> > IPPROTO_UDP ? "udp" : "tcp", host, port);
> > +if (!url)
> > +  {
> > + ERR("Could not assemble URL");
> > +  }
> > +else
> > +  {
> > + proxies = ecore_con_libproxy_proxies_get(url);
> > + eina_stringshare_del(url);
> > +  }
> 
> why are you using stringshare here?
> 
>  - this is used only once, share makes no benefit.
> 
>  - this is used from thread, not sure eina stringshare is thread safe.
> 
> if it's complaining about asprintf() on some weirdo platform, we can
> malloc + memcpy the pieces

last i knew asnprintf is "not portable" like strdupa. alloca is about the only
thing we can trust to work. :)

-- 
- Codito, ergo sum - "I code, therefore I am" --
The Rasterman (Carsten Haitzler)ras...@rasterman.com


--
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] [EGIT] [core/efl] master 02/02: ecore_con, elput: fix warnings

2016-09-20 Thread Gustavo Sverzut Barbieri
On Tue, Sep 20, 2016 at 8:26 PM, Bruno Dilly  wrote:
> cedric pushed a commit to branch master.
>
> http://git.enlightenment.org/core/efl.git/commit/?id=a3fba57b2616f78fbdab7b43ac8e8aea7c56475b
>
> commit a3fba57b2616f78fbdab7b43ac8e8aea7c56475b
> Author: Bruno Dilly 
> Date:   Tue Sep 20 16:13:25 2016 -0700
>
> ecore_con,elput: fix warnings
>
> Summary:
> elput: fix warning for unused write result
>  ecore_con: fix warning for unused asprintf result
>
> Reviewers: iscaro, devilhorns, cedric
>
> Reviewed By: cedric
>
> Subscribers: cedric, seoz, jpeg
>
> Differential Revision: https://phab.enlightenment.org/D4308
>
> Signed-off-by: Cedric BAIL 
> ---
>  src/lib/ecore_con/ecore_con.c | 15 +++
>  src/lib/elput/elput_logind.c  | 14 +-
>  2 files changed, 24 insertions(+), 5 deletions(-)
>
> diff --git a/src/lib/ecore_con/ecore_con.c b/src/lib/ecore_con/ecore_con.c
> index cc17fe8..cb66b27 100644
> --- a/src/lib/ecore_con/ecore_con.c
> +++ b/src/lib/ecore_con/ecore_con.c
> @@ -4487,11 +4487,18 @@ _efl_net_ip_connect_async_run(void *data, 
> Ecore_Thread *thread EINA_UNUSED)
>   * parameter must be a URL with schema, otherwise it won't
>   * return anything.
>   */
> -char *url;
> +Eina_Stringshare *url;
>
> -asprintf(&url, "%s://%s:%s", d->protocol == IPPROTO_UDP ? "udp" : 
> "tcp", host, port);
> -proxies = ecore_con_libproxy_proxies_get(url);
> -free(url);
> +url = eina_stringshare_printf("%s://%s:%s", d->protocol == 
> IPPROTO_UDP ? "udp" : "tcp", host, port);
> +if (!url)
> +  {
> + ERR("Could not assemble URL");
> +  }
> +else
> +  {
> + proxies = ecore_con_libproxy_proxies_get(url);
> + eina_stringshare_del(url);
> +  }

why are you using stringshare here?

 - this is used only once, share makes no benefit.

 - this is used from thread, not sure eina stringshare is thread safe.

if it's complaining about asprintf() on some weirdo platform, we can
malloc + memcpy the pieces



-- 
Gustavo Sverzut Barbieri
--
Mobile: +55 (16) 99354-9890

--
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[EGIT] [core/efl] master 02/02: ecore_con,elput: fix warnings

2016-09-20 Thread Bruno Dilly
cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=a3fba57b2616f78fbdab7b43ac8e8aea7c56475b

commit a3fba57b2616f78fbdab7b43ac8e8aea7c56475b
Author: Bruno Dilly 
Date:   Tue Sep 20 16:13:25 2016 -0700

ecore_con,elput: fix warnings

Summary:
elput: fix warning for unused write result
 ecore_con: fix warning for unused asprintf result

Reviewers: iscaro, devilhorns, cedric

Reviewed By: cedric

Subscribers: cedric, seoz, jpeg

Differential Revision: https://phab.enlightenment.org/D4308

Signed-off-by: Cedric BAIL 
---
 src/lib/ecore_con/ecore_con.c | 15 +++
 src/lib/elput/elput_logind.c  | 14 +-
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/src/lib/ecore_con/ecore_con.c b/src/lib/ecore_con/ecore_con.c
index cc17fe8..cb66b27 100644
--- a/src/lib/ecore_con/ecore_con.c
+++ b/src/lib/ecore_con/ecore_con.c
@@ -4487,11 +4487,18 @@ _efl_net_ip_connect_async_run(void *data, Ecore_Thread 
*thread EINA_UNUSED)
  * parameter must be a URL with schema, otherwise it won't
  * return anything.
  */
-char *url;
+Eina_Stringshare *url;
 
-asprintf(&url, "%s://%s:%s", d->protocol == IPPROTO_UDP ? "udp" : 
"tcp", host, port);
-proxies = ecore_con_libproxy_proxies_get(url);
-free(url);
+url = eina_stringshare_printf("%s://%s:%s", d->protocol == IPPROTO_UDP 
? "udp" : "tcp", host, port);
+if (!url)
+  {
+ ERR("Could not assemble URL");
+  }
+else
+  {
+ proxies = ecore_con_libproxy_proxies_get(url);
+ eina_stringshare_del(url);
+  }
  }
 
EINA_THREAD_CLEANUP_PUSH((Eina_Free_Cb)ecore_con_libproxy_proxies_free, 
proxies);
diff --git a/src/lib/elput/elput_logind.c b/src/lib/elput/elput_logind.c
index 5d97a02..abe4a38 100644
--- a/src/lib/elput/elput_logind.c
+++ b/src/lib/elput/elput_logind.c
@@ -276,7 +276,19 @@ _logind_device_release(Elput_Manager *em, uint32_t major, 
uint32_t minor)
 static void
 _logind_pipe_write_fd(Elput_Manager *em, int fd)
 {
-   write(em->input.pipe, &fd, sizeof(int));
+   int ret;
+
+   while (1)
+ {
+ret = write(em->input.pipe, &fd, sizeof(int));
+if (ret < 0)
+  {
+ if ((errno == EAGAIN) || (errno == EINTR))
+   continue;
+ WRN("Failed to write to input pipe");
+  }
+break;
+ }
close(em->input.pipe);
em->input.pipe = -1;
 }

--