You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2019/01/22 23:45:22 UTC

[GitHub] utzig commented on a change in pull request #1610: mgmt/imgmgr: Accept slot in `test` and `confirm` CLI commands

utzig commented on a change in pull request #1610: mgmt/imgmgr: Accept slot in `test` and `confirm` CLI commands
URL: https://github.com/apache/mynewt-core/pull/1610#discussion_r250005750
 
 

 ##########
 File path: mgmt/imgmgr/src/imgmgr_cli.c
 ##########
 @@ -114,34 +130,62 @@ imgr_cli_hash_parse(const char *arg, int *out_slot)
 
     rc = hex_parse(arg, strlen(arg), hash, sizeof hash);
     if (rc != sizeof hash) {
-        console_printf("Invalid hash: %s\n", arg);
         return SYS_EINVAL;
     }
 
     slot = imgr_find_by_hash(hash, &ver);
     if (slot == -1) {
-        console_printf("Unknown img\n");
         return SYS_ENOENT;
     }
 
     *out_slot = slot;
     return 0;
 }
 
+static int
+imgr_cli_slot_or_hash_parse(const char *arg, int *out_slot)
+{
+    int rc;
+
+    /* First, parse argument as a slot number.  Parts of the system assume slot
+     * is 0 or 1; enforce those bounds here.
+     */
+    *out_slot = parse_ll_bounds(arg, 0, 1, &rc);
+    if (rc == 0) {
 
 Review comment:
   checking `rc == SYS_EOK` would probably be better here in the long run...

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services