You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2015/11/11 22:20:13 UTC

incubator-mynewt-larva git commit: Replace dependency from snprintf() by doing conversion from uint32_t to ascii by hand.

Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master 7e35563cf -> 8e05ea117


Replace dependency from snprintf() by doing conversion from uint32_t
to ascii by hand.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/8e05ea11
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/8e05ea11
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/8e05ea11

Branch: refs/heads/master
Commit: 8e05ea11731361e9dcf47585c54a70b15f00b653
Parents: 7e35563
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Nov 11 13:19:47 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Nov 11 13:19:47 2015 -0800

----------------------------------------------------------------------
 libs/nffs/src/nffs_restore.c | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/8e05ea11/libs/nffs/src/nffs_restore.c
----------------------------------------------------------------------
diff --git a/libs/nffs/src/nffs_restore.c b/libs/nffs/src/nffs_restore.c
index 7322d03..d7328fa 100644
--- a/libs/nffs/src/nffs_restore.c
+++ b/libs/nffs/src/nffs_restore.c
@@ -71,6 +71,32 @@ nffs_restore_validate_block_chain(struct nffs_hash_entry *last_block_entry)
     return 0;
 }
 
+static void
+u32toa(char *dst, uint32_t val)
+{
+	uint8_t tmp;
+	int idx = 0;
+	int i;
+	int print = 0;
+
+	for (i = 0; i < 8; i++) {
+		tmp = val >> 28;
+		if (tmp || i == 7) {
+			print = 1;
+		}
+		if (tmp < 10) {
+			tmp += '0';
+		} else {
+			tmp += 'a' - 10;
+		}
+		if (print) {
+			dst[idx++] = tmp;
+		}
+		val <<= 4;
+	}
+	dst[idx++] = '\0';
+}
+
 /**
  * If the specified inode entry is a dummy directory, this function moves
  * all its children to the lost+found directory.
@@ -105,8 +131,9 @@ nffs_restore_migrate_orphan_children(struct nffs_inode_entry *inode_entry)
     /* Create a directory in lost+found to hold the dummy directory's
      * contents.
      */
-    snprintf(buf, sizeof buf, "/lost+found/%lu",
-            (unsigned long)inode_entry->nie_hash_entry.nhe_id);
+    strcpy(buf, "/lost+found/");
+    u32toa(&buf[strlen(buf)], inode_entry->nie_hash_entry.nhe_id);
+
     rc = nffs_path_new_dir(buf, &lost_found_sub);
     if (rc != 0 && rc != NFFS_EEXIST) {
         return rc;