refactoring: coding style 96/66296/1
authorAdrian Szyndela <adrian.s@samsung.com>
Fri, 15 Apr 2016 09:24:25 +0000 (11:24 +0200)
committerAdrian Szyndela <adrian.s@samsung.com>
Mon, 18 Apr 2016 08:23:28 +0000 (10:23 +0200)
Change-Id: I2a39f9b86a5ebbde11ee496ecc40a6cc08e6a1a1

dbus/dbus-transport-kdbus.c
dbus/kdbus-common.c
dbus/kdbus-common.h

index 8170a0c..ac8483c 100644 (file)
@@ -153,7 +153,7 @@ typedef struct DBusTransportKdbus DBusTransportKdbus;
 struct DBusTransportKdbus
 {
   DBusTransport base;                   /**< Parent instance */
-  kdbus_t   *kdbus;
+  kdbus_t   *kdbus;                     /**< kdbus data for low level operations */
   DBusWatch *read_watch;                /**< Watch for readability. */
   DBusWatch *write_watch;               /**< Watch for writability. */
 
@@ -1251,9 +1251,9 @@ request_DBus_name (DBusTransportKdbus *transport,
   dbus_uint32_t flags;
 
   if (!dbus_message_get_args (msg, error,
-                             DBUS_TYPE_STRING, &name,
-                             DBUS_TYPE_UINT32, &flags,
-                             DBUS_TYPE_INVALID))
+                              DBUS_TYPE_STRING, &name,
+                              DBUS_TYPE_UINT32, &flags,
+                              DBUS_TYPE_INVALID))
    return FALSE;
 
   _dbus_string_init_const (&service_name_real, name);
@@ -1518,8 +1518,6 @@ get_bloom (kdbus_t *kdbus, MatchRule *rule)
  * Adds a match rule to match broadcast messages going through the message bus.
  * Do no affect messages addressed directly.
  *
- * copied a lot from systemd bus_add_match_internal_kernel ()
- *
  * TODO add error reporting
  *
  * @param transport transport
@@ -2335,7 +2333,7 @@ struct CaptureHandlers {
 static struct CaptureHandlers capture_handlers[] =
 {
 // "Hello" is handled separately
-//  HANDLER_ELEMENT(Hello),
+//  HANDLER_ELEMENT (Hello),
   HANDLER_ELEMENT (RequestName),
   HANDLER_ELEMENT (ReleaseName),
   HANDLER_ELEMENT (AddMatch),
@@ -2523,11 +2521,11 @@ kdbus_message_size (const struct kdbus_msg *msg)
   const struct kdbus_item *item;
   int ret_size = 0;
 
-  KDBUS_ITEM_FOREACH(item, msg, items)
+  KDBUS_ITEM_FOREACH (item, msg, items)
     {
       if (item->size < KDBUS_ITEM_HEADER_SIZE)
         {
-          _dbus_verbose ("  +%s (%llu bytes) invalid data record\n", enum_MSG(item->type), item->size);
+          _dbus_verbose ("  +%s (%llu bytes) invalid data record\n", enum_MSG (item->type), item->size);
           return -1;
         }
       switch (item->type)
@@ -2592,10 +2590,10 @@ generate_NameSignal (const char         *signal,
  */
 static int
 kdbus_handle_name_owner_changed (__u64               type,
-                                const char         *bus_name,
-                                __u64               old,
-                                __u64               new,
-                                DBusTransportKdbus *transport)
+                                 const char         *bus_name,
+                                 __u64               old,
+                                 __u64               new,
+                                 DBusTransportKdbus *transport)
 {
   DBusMessage *message = NULL;
   DBusMessageIter args;
@@ -2686,24 +2684,24 @@ error:
 }
 
 static void
-_handle_item_timestamp (const struct kdbus_item *item)
+handle_item_timestamp (const struct kdbus_item *item)
 {
 #if KDBUS_MSG_DECODE_DEBUG == 1
   _dbus_verbose ("  +%s (%llu bytes) realtime=%lluns monotonic=%lluns\n",
-                enum_MSG(item->type), item->size,
+                enum_MSG (item->type), item->size,
                 (unsigned long long)item->timestamp.realtime_ns,
                 (unsigned long long)item->timestamp.monotonic_ns);
 #endif
 }
 
 static void
-_handle_unexpected_item (const struct kdbus_item *item)
+handle_unexpected_item (const struct kdbus_item *item)
 {
   _dbus_assert_not_reached ("unexpected item from kdbus");
 }
 
 static void
-_handle_padding (const struct kdbus_msg *msg,
+handle_padding (const struct kdbus_msg *msg,
                  const struct kdbus_item *end_of_items)
 {
 #if KDBUS_MSG_DECODE_DEBUG == 1
@@ -2901,11 +2899,11 @@ kdbus_decode_dbus_message (const struct kdbus_msg *msg,
 
   *n_fds = 0;
 
-  KDBUS_ITEM_FOREACH(item, msg, items)
+  KDBUS_ITEM_FOREACH (item, msg, items)
     {
       if (item->size < KDBUS_ITEM_HEADER_SIZE)
         {
-          _dbus_verbose ("  +%s (%llu bytes) invalid data record\n", enum_MSG(item->type), item->size);
+          _dbus_verbose ("  +%s (%llu bytes) invalid data record\n", enum_MSG (item->type), item->size);
           ret_size = -1;
           break;
         }
@@ -2923,7 +2921,7 @@ kdbus_decode_dbus_message (const struct kdbus_msg *msg,
             }
 
             _dbus_verbose ("  +%s (%llu bytes) off=%llu size=%llu\n",
-                enum_MSG(item->type), item->size,
+                enum_MSG (item->type), item->size,
                 (unsigned long long)item->vec.offset,
                 (unsigned long long)item->vec.size);
             break;
@@ -2951,7 +2949,7 @@ kdbus_decode_dbus_message (const struct kdbus_msg *msg,
               close (item->memfd.fd);
 
               _dbus_verbose ("  +%s (%llu bytes) off=%llu size=%llu\n",
-                  enum_MSG(item->type), item->size,
+                  enum_MSG (item->type), item->size,
                   (unsigned long long)item->vec.offset,
                   (unsigned long long)item->vec.size);
             }
@@ -2971,7 +2969,7 @@ kdbus_decode_dbus_message (const struct kdbus_msg *msg,
           case KDBUS_ITEM_CREDS:
 #if KDBUS_MSG_DECODE_DEBUG == 1
             _dbus_verbose ("  +%s (%llu bytes) uid=%lld, gid=%lld, pid=%lld, tid=%lld, starttime=%lld\n",
-                          enum_MSG(item->type), item->size,
+                          enum_MSG (item->type), item->size,
                           item->creds.uid, item->creds.gid,
                           item->creds.pid, item->creds.tid,
                           item->creds.starttime);
@@ -2986,7 +2984,7 @@ kdbus_decode_dbus_message (const struct kdbus_msg *msg,
           case KDBUS_ITEM_DST_NAME:
 #if KDBUS_MSG_DECODE_DEBUG == 1
             _dbus_verbose ("  +%s (%llu bytes) '%s' (%zu)\n",
-                          enum_MSG(item->type), item->size, item->str, strlen (item->str));
+                          enum_MSG (item->type), item->size, item->str, strlen (item->str));
 #endif
             break;
 
@@ -2998,7 +2996,7 @@ kdbus_decode_dbus_message (const struct kdbus_msg *msg,
               const char *str = item->str;
               int count = 0;
 
-              _dbus_verbose ("  +%s (%llu bytes) ", enum_MSG(item->type), item->size);
+              _dbus_verbose ("  +%s (%llu bytes) ", enum_MSG (item->type), item->size);
               while (size)
               {
                 _dbus_verbose ("'%s' ", str);
@@ -3015,7 +3013,7 @@ kdbus_decode_dbus_message (const struct kdbus_msg *msg,
           case KDBUS_ITEM_AUDIT:
 #if KDBUS_MSG_DECODE_DEBUG == 1
             _dbus_verbose ("  +%s (%llu bytes) loginuid=%llu sessionid=%llu\n",
-                          enum_MSG(item->type), item->size,
+                          enum_MSG (item->type), item->size,
                           (unsigned long long)item->data64[0],
                           (unsigned long long)item->data64[1]);
 #endif
@@ -3029,7 +3027,7 @@ kdbus_decode_dbus_message (const struct kdbus_msg *msg,
               int i;
 
               _dbus_verbose ("  +%s (%llu bytes) len=%llu bytes)\n",
-                  enum_MSG(item->type), item->size,
+                  enum_MSG (item->type), item->size,
                   (unsigned long long)item->size - KDBUS_ITEM_HEADER_SIZE);
 
               cap = item->data32;
@@ -3056,7 +3054,7 @@ kdbus_decode_dbus_message (const struct kdbus_msg *msg,
             break;
 
           case KDBUS_ITEM_TIMESTAMP:
-            _handle_item_timestamp (item);
+            handle_item_timestamp (item);
             break;
 
           case KDBUS_ITEM_BLOOM_FILTER:
@@ -3064,12 +3062,12 @@ kdbus_decode_dbus_message (const struct kdbus_msg *msg,
             break;
 
           default:
-            _handle_unexpected_item (item);
+            handle_unexpected_item (item);
             break;
         }
     }
 
-  _handle_padding (msg, item);
+  handle_padding (msg, item);
 
   if (!can_receive (kdbus_transport, msg, buffer, ret_size))
     return 0;   /* ignore message if not allowed */
@@ -3124,7 +3122,7 @@ kdbus_decode_kernel_message (const struct kdbus_msg *msg,
               int local_ret;
 
               _dbus_verbose ("  +%s (%llu bytes) '%s', old id=%lld, new id=%lld, old flags=0x%llx, new flags=0x%llx\n",
-                             enum_MSG(item->type), (unsigned long long) item->size,
+                             enum_MSG (item->type), (unsigned long long) item->size,
                              item->name_change.name, item->name_change.old_id.id,
                              item->name_change.new_id.id, item->name_change.old_id.flags,
                              item->name_change.new_id.flags);
@@ -3163,7 +3161,7 @@ kdbus_decode_kernel_message (const struct kdbus_msg *msg,
           case KDBUS_ITEM_ID_ADD:
           case KDBUS_ITEM_ID_REMOVE:
             _dbus_verbose ("  +%s (%llu bytes) id=%llu flags=%llu\n",
-                          enum_MSG(item->type), (unsigned long long) item->size,
+                          enum_MSG (item->type), (unsigned long long) item->size,
                           (unsigned long long) item->id_change.id,
                           (unsigned long long) item->id_change.flags);
 
@@ -3181,16 +3179,16 @@ kdbus_decode_kernel_message (const struct kdbus_msg *msg,
             break;
 
           case KDBUS_ITEM_TIMESTAMP:
-            _handle_item_timestamp (item);
+            handle_item_timestamp (item);
             break;
 
           default:
-            _handle_unexpected_item (item);
+            handle_unexpected_item (item);
             break;
         }
     }
 
-  _handle_padding (msg, item);
+  handle_padding (msg, item);
 
 out:
   return ret_size;
@@ -3220,7 +3218,7 @@ kdbus_decode_msg (const struct kdbus_msg *msg,
 
 #if KDBUS_MSG_DECODE_DEBUG == 1
   _dbus_verbose ("MESSAGE: %s (%llu bytes) flags=0x%llx, %s → %s, cookie=%llu, timeout=%llu\n",
-                enum_PAYLOAD(msg->payload_type),
+                enum_PAYLOAD (msg->payload_type),
                 (unsigned long long) msg->size,
                 (unsigned long long) msg->flags,
                 msg_id (msg->src_id),
@@ -3292,7 +3290,7 @@ kdbus_read_message (DBusTransportKdbus *kdbus_transport,
 
   /* What is the maximum size of the locally generated message?
      I just assume 2048 bytes */
-  buf_size = MAX(buf_size, 2048);
+  buf_size = MAX (buf_size, 2048);
 
   if (!_dbus_string_lengthen (buffer, buf_size))
     {
@@ -3836,7 +3834,7 @@ kdbus_connection_set (DBusTransport *transport)
  * could block a write call forever (if there are no incoming
  * messages).
  */
-static  void
+static void
 kdbus_do_iteration (DBusTransport *transport,
                    unsigned int   flags,
                    int            timeout_milliseconds)
index 65c55a2..7585b1f 100644 (file)
@@ -50,7 +50,7 @@ struct kdbus_t
                                      */
   size_t pool_size;                                     /**< Size of mapped memory */
   __u64 id;                                       /**< unique id of the connection */
-  char bus_id[sizeof(((struct kdbus_cmd_hello *)(0))->id128)];  /**< id of the bus */
+  char bus_id[sizeof (((struct kdbus_cmd_hello *)(0))->id128)];  /**< id of the bus */
   struct kdbus_bloom_parameter bloom;                         /**< bloom parameters*/
 };
 
@@ -59,7 +59,7 @@ int _kdbus_fd (kdbus_t *kdbus) { return kdbus->fd; }
 void *_kdbus_mmap_ptr (kdbus_t *kdbus) { return kdbus->mmap_ptr; }
 dbus_uint64_t _kdbus_id (kdbus_t *kdbus) { return kdbus->id; }
 char *_kdbus_bus_id (kdbus_t *kdbus) { return kdbus->bus_id; }
-dbus_uint64_t _kdbus_bus_id_size (void) { return sizeof(((struct kdbus_t *)(0))->bus_id); }
+dbus_uint64_t _kdbus_bus_id_size (void) { return sizeof (((struct kdbus_t *)(0))->bus_id); }
 struct kdbus_bloom_parameter *_kdbus_bloom (kdbus_t *kdbus) { return &kdbus->bloom; }
 
 
@@ -103,13 +103,13 @@ free_by_offset (kdbus_t  *kdbus,
   return 0;
 }
 
-static void make_item_name(const char *name, struct kdbus_item *item)
+static void make_item_name (const char *name, struct kdbus_item *item)
 {
-  size_t len = strlen(name) + 1;
+  size_t len = strlen (name) + 1;
   item->size = KDBUS_ITEM_HEADER_SIZE + len;
   item->type = KDBUS_ITEM_NAME;
 
-  memcpy(item->str, name, len);
+  memcpy (item->str, name, len);
 }
 
 /**
@@ -386,7 +386,7 @@ _kdbus_send (kdbus_t           *kdbus,
 {
   struct kdbus_cmd_send cmd;
 
-  cmd.size = sizeof(cmd);
+  cmd.size = sizeof (cmd);
   cmd.msg_address = (__u64)msg;
   cmd.flags = flags;
 
@@ -676,32 +676,32 @@ _kdbus_request_name (kdbus_t     *kdbus,
                      const __u64  flags)
 {
   struct kdbus_cmd *cmd_name;
-  size_t len = strlen(name) + 1;
+  size_t len = strlen (name) + 1;
 
-  __u64 size = sizeof(*cmd_name) + KDBUS_ITEM_SIZE(len);
+  __u64 size = sizeof (*cmd_name) + KDBUS_ITEM_SIZE (len);
   __u64 flags_kdbus = 0;
 
-  cmd_name = alloca(size);
+  cmd_name = alloca (size);
   cmd_name->size = size;
 
-  if(flags & DBUS_NAME_FLAG_ALLOW_REPLACEMENT)
+  if (flags & DBUS_NAME_FLAG_ALLOW_REPLACEMENT)
     flags_kdbus |= KDBUS_NAME_ALLOW_REPLACEMENT;
-  if(!(flags & DBUS_NAME_FLAG_DO_NOT_QUEUE))
+  if (!(flags & DBUS_NAME_FLAG_DO_NOT_QUEUE))
     flags_kdbus |= KDBUS_NAME_QUEUE;
-  if(flags & DBUS_NAME_FLAG_REPLACE_EXISTING)
+  if (flags & DBUS_NAME_FLAG_REPLACE_EXISTING)
     flags_kdbus |= KDBUS_NAME_REPLACE_EXISTING;
 
   cmd_name->flags = flags_kdbus;
-  make_item_name(name, &(cmd_name->items[0]));
+  make_item_name (name, &(cmd_name->items[0]));
 
-  _dbus_verbose("Request name - flags sent: 0x%llx       !!!!!!!!!\n", cmd_name->flags);
+  _dbus_verbose ("Request name - flags sent: 0x%llx       !!!!!!!!!\n", cmd_name->flags);
 
-  if (ioctl(kdbus->fd, KDBUS_CMD_NAME_ACQUIRE, cmd_name) < 0)
+  if (ioctl (kdbus->fd, KDBUS_CMD_NAME_ACQUIRE, cmd_name) < 0)
     {
       _dbus_verbose ("error acquiring name '%s': %m, %d\n", name, errno);
-      if(errno == EEXIST)
+      if (errno == EEXIST)
         return DBUS_REQUEST_NAME_REPLY_EXISTS;
-      if(errno == EALREADY)
+      if (errno == EALREADY)
         return DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER;
       return -errno;
     }
@@ -709,9 +709,9 @@ _kdbus_request_name (kdbus_t     *kdbus,
        && !(cmd_name->return_flags & KDBUS_NAME_ACQUIRED))
     return DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER;
 
-  _dbus_verbose("Request name - received flag: 0x%llx       !!!!!!!!!\n", cmd_name->flags);
+  _dbus_verbose ("Request name - received flag: 0x%llx       !!!!!!!!!\n", cmd_name->flags);
 
-  if(cmd_name->return_flags & KDBUS_NAME_IN_QUEUE)
+  if (cmd_name->return_flags & KDBUS_NAME_IN_QUEUE)
     return DBUS_REQUEST_NAME_REPLY_IN_QUEUE;
 
   return DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER;
@@ -723,7 +723,6 @@ _kdbus_request_name (kdbus_t     *kdbus,
  * which can be then assigned to another connection or the connection
  * is being removed from the queue for that name
  *
- * @param fd - file descriptor of the connection
  * @param name the name to request
  * @param id unique id of the connection for which the name is being released
  * @returns a DBus result code on success, -errno on error
@@ -734,17 +733,17 @@ _kdbus_release_name (kdbus_t    *kdbus,
 {
   struct kdbus_cmd *cmd_name;
 
-  size_t len = strlen(name)+1;
-  __u64 size = sizeof(*cmd_name) + KDBUS_ITEM_SIZE(len);
+  size_t len = strlen (name)+1;
+  __u64 size = sizeof (*cmd_name) + KDBUS_ITEM_SIZE (len);
 
-  cmd_name = alloca(size);
+  cmd_name = alloca (size);
   cmd_name->size = size;
   cmd_name->flags = 0;
-  make_item_name(name, &(cmd_name->items[0]));
+  make_item_name (name, &(cmd_name->items[0]));
 
-  if (ioctl(kdbus->fd, KDBUS_CMD_NAME_RELEASE, cmd_name))
+  if (ioctl (kdbus->fd, KDBUS_CMD_NAME_RELEASE, cmd_name))
     {
-      if((errno == ESRCH))
+      if ((errno == ESRCH))
         return DBUS_RELEASE_NAME_REPLY_NON_EXISTENT;
       else if (errno == EADDRINUSE)
         return DBUS_RELEASE_NAME_REPLY_NOT_OWNER;
@@ -752,7 +751,7 @@ _kdbus_release_name (kdbus_t    *kdbus,
       return -errno;
     }
 
-  _dbus_verbose("Name '%s' released\n", name);
+  _dbus_verbose ("Name '%s' released\n", name);
 
   return DBUS_RELEASE_NAME_REPLY_RELEASED;
 }
@@ -764,7 +763,7 @@ decode_connection_info (struct kdbus_info *connection_info,
 {
   struct kdbus_item *item;
 
-  memset (pInfo, 0, sizeof(*pInfo));
+  memset (pInfo, 0, sizeof (*pInfo));
 
   pInfo->uniqueId = connection_info->id;
   pInfo->flags = connection_info->flags;
@@ -832,10 +831,10 @@ process_connection_info_cmd (kdbus_t               *kdbus,
   ret = free_by_offset (kdbus, cmd->offset);
   if (ret != 0)
     {
-      _dbus_verbose("kdbus error freeing pool: %d (%m)\n", errno);
+      _dbus_verbose ("kdbus error freeing pool: %d (%m)\n", errno);
       if (get_sec_label)
         {
-          free(pInfo->sec_label);
+          free (pInfo->sec_label);
           pInfo->sec_label = NULL;
         }
     }
@@ -851,7 +850,7 @@ prepare_connection_info_cmd (dbus_uint64_t  id,
                              dbus_bool_t    get_sec_label)
 {
   struct kdbus_cmd_info *cmd;
-  dbus_uint64_t size = sizeof(*cmd);
+  dbus_uint64_t size = sizeof (*cmd);
   if (NULL != name)
     {
       size += KDBUS_ITEM_SIZE (strlen (name) + 1);
@@ -918,10 +917,10 @@ _kdbus_connection_info_by_name (kdbus_t         *kdbus,
   struct kdbus_cmd_info *cmd;
 
   /* if name starts with ":1." it is a unique name and should be send as number */
-  if((name[0] == ':') && (name[1] == '1') && (name[2] == '.'))
+  if ((name[0] == ':') && (name[1] == '1') && (name[2] == '.'))
   {
     return _kdbus_connection_info_by_id (kdbus,
-                                         strtoull(&name[3], NULL, 10),
+                                         strtoull (&name[3], NULL, 10),
                                          get_sec_label,
                                          pInfo);
   }
@@ -946,7 +945,7 @@ remove_match_kdbus (kdbus_t *kdbus,
   struct kdbus_cmd_match cmd;
 
   cmd.cookie = cookie;
-  cmd.size = sizeof(struct kdbus_cmd_match);
+  cmd.size = sizeof (struct kdbus_cmd_match);
   cmd.flags = 0;
 
   if(ioctl (kdbus->fd, KDBUS_CMD_MATCH_REMOVE, &cmd))
@@ -990,7 +989,7 @@ _kdbus_remove_match (kdbus_t    *kdbus,
 
           if (match_rule_equal_lib (rule, rule_to_remove))
             {
-              cookie = match_rule_get_cookie(rule);
+              cookie = match_rule_get_cookie (rule);
               break;
             }
 
@@ -998,14 +997,14 @@ _kdbus_remove_match (kdbus_t    *kdbus,
         }
     }
 
-  if(cookie == 0)
+  if (cookie == 0)
     {
       dbus_set_error (error, DBUS_ERROR_MATCH_RULE_NOT_FOUND,
                       "The given match rule wasn't found and can't be removed");
       return FALSE;
     }
 
-  if(!remove_match_kdbus (kdbus, cookie))
+  if (!remove_match_kdbus (kdbus, cookie))
     {
       dbus_set_error (error, _dbus_error_from_errno (errno), "Could not remove match rule");
       return FALSE;
index f03dc92..fb5bcda 100644 (file)
@@ -100,7 +100,7 @@ int         _kdbus_add_match_id_change             (kdbus_t *kdbus,
                                                     dbus_uint64_t id,
                                                     dbus_uint64_t id_flags);
 
-int         _kdbus_add_match                      (kdbus_t *kdbus,
+int         _kdbus_add_match                      (kdbus_t                *kdbus,
                                                    struct kdbus_cmd_match *cmd);
 
 int         _kdbus_connection_info_by_name         (kdbus_t         *kdbus,