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 2018/11/02 09:56:14 UTC

[GitHub] nvlsianpu commented on a change in pull request #13: Add support for resuming partial upload

nvlsianpu commented on a change in pull request #13: Add support for resuming partial upload
URL: https://github.com/apache/mynewt-mcumgr/pull/13#discussion_r230302063
 
 

 ##########
 File path: cmd/img_mgmt/src/img_mgmt.c
 ##########
 @@ -270,26 +279,35 @@ img_mgmt_encode_upload_rsp(struct mgmt_ctxt *ctxt, int status)
     return 0;
 }
 
-/**
- * Processes an upload request specifying an offset of 0 (i.e., the first image
- * chunk).  The caller is responsible for encoding the response.
- */
+/* check if header for first packet is valid */
 static int
-img_mgmt_upload_first_chunk(struct mgmt_ctxt *ctxt, const uint8_t *req_data,
-                            size_t len)
+img_mgmt_check_header(const uint8_t *req_data, size_t len)
 {
     struct image_header hdr;
-    int rc;
 
-    if (len < sizeof hdr) {
+    if (len < sizeof(hdr)) {
         return MGMT_ERR_EINVAL;
     }
 
-    memcpy(&hdr, req_data, sizeof hdr);
+    memcpy(&hdr, req_data, sizeof(hdr));
 
 Review comment:
   unnecessary copy.
   `if ((struct image_header*)req_data)->ih_magic != IMAGE_MAGIC)`

----------------------------------------------------------------
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