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/06/12 16:57:20 UTC

[GitHub] [mynewt-core] ccollins476ad commented on a change in pull request #1864: mgmt/imgmgr: Log image management events

ccollins476ad commented on a change in pull request #1864: mgmt/imgmgr: Log image management events
URL: https://github.com/apache/mynewt-core/pull/1864#discussion_r293019350
 
 

 ##########
 File path: mgmt/imgmgr/src/imgmgr.c
 ##########
 @@ -743,6 +743,45 @@ imgr_upload_good_rsp(struct mgmt_cbuf *cb)
     return 0;
 }
 
+/**
+ * Logs an upload request if necessary.
+ *
+ * @param is_first              Whether the request includes the first chunk of
+ *                                  the image.
+ * @param is_last               Whether the request includes the last chunk of
+ *                                  the image.
+ * @param status                The result of processing the upload request
+ *                                  (MGMT_ERR code).
+ *
+ * @return                      0 on success; nonzero on failure.
+ */
+static int
+imgr_upload_log(bool is_first, bool is_last, int status)
+{
+    uint8_t hash[IMGMGR_HASH_LEN];
+    const uint8_t *hashp;
+    int rc;
+
+    if (is_first) {
+        return imgmgr_log_upload_start(status);
+    }
+
+    /* Log the image hash if we know it. */
+    rc = imgr_read_info(1, NULL, hash, NULL);
 
 Review comment:
   Thanks @mkiiskila, that is a good point.  I have changed the function as follows:
   ```
   static int
   imgr_upload_log(bool is_first, bool is_last, int status)
   {
       uint8_t hash[IMGMGR_HASH_LEN];
       const uint8_t *hashp;
       int rc;
   
       if (is_first) {
           return imgmgr_log_upload_start(status);
       }
   
       if (is_last || status != 0) {
           /* Log the image hash if we know it. */
           rc = imgr_read_info(1, NULL, hash, NULL);
           if (rc != 0) {
               hashp = NULL;
           } else {
               hashp = hash;
           }
   
           return imgmgr_log_upload_done(status, hashp);
       }
   
       /* Nothing to log. */
       return 0;
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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