You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by st...@apache.org on 2016/09/27 19:26:39 UTC

incubator-mynewt-core git commit: change split code to adhere to coding standards

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 313680919 -> 1529b281f


change split code to adhere to coding standards


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/1529b281
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/1529b281
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/1529b281

Branch: refs/heads/develop
Commit: 1529b281f40d2478548d3b7f918c1000153ba9a0
Parents: 3136809
Author: Sterling Hughes <st...@apache.org>
Authored: Tue Sep 27 12:26:32 2016 -0700
Committer: Sterling Hughes <st...@apache.org>
Committed: Tue Sep 27 12:26:32 2016 -0700

----------------------------------------------------------------------
 libs/split/include/split/split.h      | 16 +++++++--------
 libs/split/include/split/split_priv.h | 19 +++++-------------
 libs/split/src/split.c                | 31 ++++++++++++++++--------------
 libs/split/src/split_config.c         | 17 ++++++++++------
 libs/split/src/split_netmgr.c         | 21 ++++++++++----------
 5 files changed, 50 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1529b281/libs/split/include/split/split.h
----------------------------------------------------------------------
diff --git a/libs/split/include/split/split.h b/libs/split/include/split/split.h
index fa31369..0cf78e3 100644
--- a/libs/split/include/split/split.h
+++ b/libs/split/include/split/split.h
@@ -22,23 +22,22 @@
 
 #define SPLIT_NMGR_OP_SPLIT 0
 
-typedef enum splitMode_e {
+typedef enum {
     SPLIT_NONE,
     SPLIT_TEST,
     SPLIT_RUN,
-} splitMode_t;
+} split_mode_t;
 
 
-typedef enum splitStatus_e {
+typedef enum {
     SPLIT_INVALID,
     SPLIT_NOT_MATCHING,
     SPLIT_MATCHING,
-}splitStatus_t;
+} split_status_t;
 
 /*
   * Initializes the split application library */
-void
-split_app_init(void);
+void split_app_init(void);
 
 /**
   * checks the split application state.
@@ -51,9 +50,8 @@ split_app_init(void);
   * to prepare to boot.  An application may set toBoot to
   * false and call this function to check whether the split
   * application is bootable.
- * 
+ *
  * @Returns zero on success, non-zero on failures */
-int
-split_app_go(void **entry, int toBoot);
+int split_app_go(void **entry, int toboot);
 
 #endif /* _SPLIT_H__ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1529b281/libs/split/include/split/split_priv.h
----------------------------------------------------------------------
diff --git a/libs/split/include/split/split_priv.h b/libs/split/include/split/split_priv.h
index f836ea0..0478b75 100644
--- a/libs/split/include/split/split_priv.h
+++ b/libs/split/include/split/split_priv.h
@@ -20,20 +20,11 @@
 #ifndef SPLIT_PRIV_H
 #define SPLIT_PRIV_H
 
-int
-split_conf_init(void);
-
-int
-split_nmgr_register(void);
-
-int
-split_read_split(splitMode_t *split);
-
-int
-split_write_split(splitMode_t mode);
-
-splitStatus_t
-split_check_status(void);
+int split_conf_init(void);
+int split_nmgr_register(void);
+int split_read_split(split_mode_t *split);
+int split_write_split(split_mode_t mode);
+split_status_t split_check_status(void);
 
 #endif /* SPLIT_PRIV_H */
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1529b281/libs/split/src/split.c
----------------------------------------------------------------------
diff --git a/libs/split/src/split.c b/libs/split/src/split.c
index bcb7488..cd0e528 100644
--- a/libs/split/src/split.c
+++ b/libs/split/src/split.c
@@ -6,13 +6,13 @@
 #include <split/split.h>
 #include <split/split_priv.h>
 
-
 #define LOADER_IMAGE_SLOT    0
 #define SPLIT_IMAGE_SLOT    1
 #define SPLIT_TOTAL_IMAGES  2
 
 void
-split_app_init(void) {
+split_app_init(void)
+{
     int rc;
 
     rc = split_conf_init();
@@ -22,16 +22,19 @@ split_app_init(void) {
     assert(rc==0);
 }
 
-splitStatus_t
-split_check_status(void) {
-    int rc;
+split_status_t
+split_check_status(void)
+{
     void *entry;
-    rc =split_go(LOADER_IMAGE_SLOT, SPLIT_IMAGE_SLOT, &entry);
+    int rc;
+
+    rc = split_go(LOADER_IMAGE_SLOT, SPLIT_IMAGE_SLOT, &entry);
 
     if(rc == SPLIT_GO_ERR) {
         return SPLIT_INVALID;
     } else if (rc) {
     }
+
     return SPLIT_MATCHING;
 }
 
@@ -43,14 +46,13 @@ split_check_status(void) {
  *
  * @return                      0 on success; nonzero on failure.
  */
-
-
 int
-split_app_go(void **entry, int toBoot) {
-    splitMode_t split;
+split_app_go(void **entry, int toboot)
+{
+    split_mode_t split;
     int rc;
 
-    if (toBoot) {
+    if (toboot) {
         /* if we can't read this, then we don't boot an app */
         rc = split_read_split(&split);
         if(rc) {
@@ -58,7 +60,7 @@ split_app_go(void **entry, int toBoot) {
         }
 
         /* if we are told not to, then we don't boot an app */
-        if(split == SPLIT_NONE) {
+        if (split == SPLIT_NONE) {
             return -1;
         }
 
@@ -68,7 +70,8 @@ split_app_go(void **entry, int toBoot) {
         }
     }
 
-    rc =split_go(LOADER_IMAGE_SLOT, SPLIT_IMAGE_SLOT, entry);
-    return rc;
+    rc = split_go(LOADER_IMAGE_SLOT, SPLIT_IMAGE_SLOT, entry);
+
+    return (rc);
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1529b281/libs/split/src/split_config.c
----------------------------------------------------------------------
diff --git a/libs/split/src/split_config.c b/libs/split/src/split_config.c
index 5f7cefa..57332da 100644
--- a/libs/split/src/split_config.c
+++ b/libs/split/src/split_config.c
@@ -23,14 +23,18 @@ static struct conf_handler split_conf_handler = {
     .ch_export = split_conf_export
 };
 
+static int8_t split_status;
+
 int
-split_conf_init(void) {
+split_conf_init(void)
+{
     int rc;
+
     rc = conf_register(&split_conf_handler);
+
     return rc;
 }
 
-static int8_t split_status;
 
 static char *
 split_conf_get(int argc, char **argv, char *buf, int max_len)
@@ -71,15 +75,16 @@ split_conf_export(void (*func)(char *name, char *val), enum conf_export_tgt tgt)
 }
 
 int
-split_read_split(splitMode_t *split) {
-    *split = (splitMode_t) split_status;
+split_read_split(split_mode_t *split)
+{
+    *split = (split_mode_t) split_status;
     return 0;
 }
 
 int
-split_write_split(splitMode_t split)
+split_write_split(split_mode_t split)
 {
-    char str[CONF_STR_FROM_BYTES_LEN(sizeof(splitMode_t))];
+    char str[CONF_STR_FROM_BYTES_LEN(sizeof(split_mode_t))];
 
     split_status = (int8_t) split;
     if (!conf_str_from_value(CONF_INT8, &split_status, str, sizeof(str))) {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/1529b281/libs/split/src/split_netmgr.c
----------------------------------------------------------------------
diff --git a/libs/split/src/split_netmgr.c b/libs/split/src/split_netmgr.c
index 9ec3010..7d2e7dc 100644
--- a/libs/split/src/split_netmgr.c
+++ b/libs/split/src/split_netmgr.c
@@ -35,10 +35,10 @@ static const struct nmgr_handler split_nmgr_handlers[] = {
     },
 };
 
-    static struct nmgr_group split_nmgr_group = {
+static struct nmgr_group split_nmgr_group = {
     .ng_handlers = (struct nmgr_handler *)split_nmgr_handlers,
     .ng_handlers_count =
-    sizeof(split_nmgr_handlers) / sizeof(split_nmgr_handlers[0]),
+        sizeof(split_nmgr_handlers) / sizeof(split_nmgr_handlers[0]),
     .ng_group_id = NMGR_GROUP_ID_SPLIT,
 };
 
@@ -47,14 +47,15 @@ split_nmgr_register(void)
 {
     int rc;
     rc = nmgr_group_register(&split_nmgr_group);
-    return rc;
+    return (rc);
 }
+
 int
 imgr_splitapp_read(struct nmgr_jbuf *njb)
 {
     int rc;
     int x;
-    splitMode_t split;
+    split_mode_t split;
     struct json_encoder *enc;
     struct json_value jv;
 
@@ -86,23 +87,22 @@ imgr_splitapp_read(struct nmgr_jbuf *njb)
 int
 imgr_splitapp_write(struct nmgr_jbuf *njb)
 {
-    long long int splitMode;
-    long long int sendSplitStatus;  /* ignored */
+    long long int split_mode;
+    long long int send_split_status;  /* ignored */
     long long int sent_rc; /* ignored */
-
     const struct json_attr_t split_write_attr[4] = {
         [0] =
         {
             .attribute = "splitMode",
             .type = t_integer,
-            .addr.integer = &splitMode,
+            .addr.integer = &split_mode,
             .nodefault = true,
         },
         [1] =
         {
             .attribute = "splitStatus",
             .type = t_integer,
-            .addr.integer = &sendSplitStatus,
+            .addr.integer = &send_split_status,
             .nodefault = true,
         },
         [2] =
@@ -127,7 +127,7 @@ imgr_splitapp_write(struct nmgr_jbuf *njb)
         goto err;
     }
 
-    rc = split_write_split((splitMode_t) splitMode);
+    rc = split_write_split((split_mode_t) split_mode);
     if (rc) {
         rc = NMGR_ERR_EINVAL;
         goto err;
@@ -143,7 +143,6 @@ imgr_splitapp_write(struct nmgr_jbuf *njb)
     json_encode_object_finish(enc);
 
     return 0;
-
 err:
     nmgr_jbuf_setoerr(njb, rc);
     return 0;