From 78baef1dd60e176c052f769187bde7552233f673 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Mon, 21 Jul 2008 11:42:49 +0300 Subject: [PATCH] obexd: Coding style and whitespace fixes --- obexd/src/ftp.c | 8 ++++---- obexd/src/manager.c | 3 +-- obexd/src/obex.c | 34 ++++++++++++++++------------------ obexd/src/opp.c | 4 +--- 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/obexd/src/ftp.c b/obexd/src/ftp.c index fea782c99..e730ece82 100644 --- a/obexd/src/ftp.c +++ b/obexd/src/ftp.c @@ -128,6 +128,7 @@ static gboolean folder_listing(struct obex_session *os, guint32 *size) } dp = opendir(os->current_folder); + while (dp && (ep = readdir(dp))) { gchar *name; gchar *fullname; @@ -158,11 +159,13 @@ static gboolean folder_listing(struct obex_session *os, guint32 *size) g_free(name); continue; } + g_free(name); listing = g_string_append(listing, line); g_free(line); } + closedir(dp); listing = g_string_append(listing, FL_BODY_END); @@ -182,9 +185,8 @@ static gboolean get_capability(struct obex_session *os, guint32 *size) if (os->server->capability == NULL) return FALSE; - if (os->server->capability[0] != '!') { + if (os->server->capability[0] != '!') return os_prepare_get(os, os->server->capability, size); - } ret = g_spawn_command_line_sync(os->server->capability + 1, &buf, NULL, &exit, &gerr); @@ -269,8 +271,6 @@ void ftp_get(obex_t *obex, obex_object_t *obj) fail: OBEX_ObjectSetRsp(obj, OBEX_RSP_FORBIDDEN, OBEX_RSP_FORBIDDEN); - - return; } static gint ftp_delete(struct obex_session *os) diff --git a/obexd/src/manager.c b/obexd/src/manager.c index 3024d5498..2c8468048 100644 --- a/obexd/src/manager.c +++ b/obexd/src/manager.c @@ -559,9 +559,8 @@ int request_authorization(gint32 cid, int fd, const gchar *filename, dbus_pending_call_cancel(call); dbus_pending_call_unref(call); - if (!agent || !agent->new_name) { + if (!agent || !agent->new_name) return -EPERM; - } *new_folder = agent->new_folder; *new_name = agent->new_name; diff --git a/obexd/src/obex.c b/obexd/src/obex.c index 0bfdff9ba..dc3b9bb41 100644 --- a/obexd/src/obex.c +++ b/obexd/src/obex.c @@ -227,7 +227,6 @@ static void cmd_connect(struct obex_session *os, OBEX_FL_FIT_ONE_PACKET); OBEX_ObjectSetRsp(obj, OBEX_RSP_CONTINUE, OBEX_RSP_SUCCESS); - } static gboolean chk_cid(obex_t *obex, obex_object_t *obj, guint32 cid) @@ -354,27 +353,26 @@ static void cmd_setpath(struct obex_session *os, } while (OBEX_ObjectGetNextHeader(obex, obj, &hi, &hd, &hlen)) { - if (hi == OBEX_HDR_NAME) { - if (os->name) { - debug("Ignoring multiple name headers"); - break; - } - - /* - * This is because OBEX_UnicodeToChar() accesses - * the string even if its size is zero - */ - if (hlen == 0) { - os->name = g_strdup(""); - break; - } + if (hi != OBEX_HDR_NAME) + continue; - os->name = g_convert((const gchar *) hd.bs, hlen, - "UTF8", "UTF16BE", NULL, NULL, NULL); + if (os->name) { + debug("Ignoring multiple name headers"); + break; + } - debug("Set path name: %s", os->name); + /* This is because OBEX_UnicodeToChar() accesses the string + even if its size is zero */ + if (hlen == 0) { + os->name = g_strdup(""); break; } + + os->name = g_convert((const gchar *) hd.bs, hlen, + "UTF8", "UTF16BE", NULL, NULL, NULL); + + debug("Set path name: %s", os->name); + break; } os->cmds->setpath(obex, obj); diff --git a/obexd/src/opp.c b/obexd/src/opp.c index 390b07420..c34899e4f 100644 --- a/obexd/src/opp.c +++ b/obexd/src/opp.c @@ -70,7 +70,7 @@ gint opp_chkput(obex_t *obex, obex_object_t *obj) os->name ? os->name : "", os->type ? os->type : "", os->size, time, &new_folder, - &new_name); + &new_name); if (ret < 0) return -EPERM; @@ -151,6 +151,4 @@ void opp_get(obex_t *obex, obex_object_t *obj) fail: OBEX_ObjectSetRsp(obj, OBEX_RSP_FORBIDDEN, OBEX_RSP_FORBIDDEN); - - return; } -- 2.47.3