cld: read the cld.port file using g_file_get_contents
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v3 2/2 cld: read the cld.port file using g_file_get_contents
Signed-off-by Colin McCabe <[email protected]>
--- lib/common.c | 27 +++++++++++++-------------- 1 files changed, 13 insertions(+), 14 deletions(-)
lib/common.c +13 -14
@@ -61,26 +61,25 @@ const char *cld_errstr(enum cle_err_codes ecode)*/ int cld_readport (const char *fname) { -enum {LEN =11 }; -char buf[LEN +1 ];long port; -int fd; -int rc; +gchar *buf; +GError *err =NULL ; +gsize len; -if ((fd =open (fname,O_RDONLY )) ==-1 ) -return -errno; - rc =read (fd, buf,LEN ); -close (fd); -if (rc <0 ) -return -errno; -if (rc ==0 ) -return -EPIPE ; - buf[rc] =0 ; +if (!g_file_get_contents (fname, &buf, &len, &err)) { +int ret =-1000 - err->code; +g_error_free (err); +return ret; + } +if (len ==0 ) { +g_free (buf); +return -EPIPE ; + } port =strtol (buf,NULL ,10 ); +g_free (buf);if (port <=0 || port >=65636 )return -EDOM ;return (int )port; } -
Signature · 1 line
1.6.2.5
Jeff Garzik
AppliedQuoted 4 lines · Colin McCabe
Signed-off-by Colin McCabe<[email protected]>--- lib/common.c | 27 +++++++++++++-------------- 1 files changed, 13 insertions(+), 14 deletions(-)
applied, thanks for the revisions