Fix a defect detected by static code analyzer
authorJaewook Jung <jw0213.jung@samsung.com>
Thu, 13 Apr 2017 05:55:15 +0000 (14:55 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Mon, 17 Apr 2017 04:41:26 +0000 (04:41 +0000)
unsigned int is always greater than or equal to zero.

Change-Id: I2aa83c4a224e5bbaf22882ccb131161850dcee57
Signed-off-by: Jaewook Jung <jw0213.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18879
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
resource/csdk/connectivity/src/cablockwisetransfer.c

index 21e16be..6cbcdc0 100644 (file)
@@ -1923,7 +1923,7 @@ uint8_t CACheckBlockErrorType(CABlockData_t *currData, coap_block_t *receivedBlo
             OIC_LOG(ERROR, TAG, "too large size");
 
             // set the block size to be smaller than COAP_MAX_PDU_SIZE
-            for (unsigned int size = CA_DEFAULT_BLOCK_SIZE; size >= 0; size--)
+            for (unsigned int size = CA_DEFAULT_BLOCK_SIZE; ; size--)
             {
                 if (COAP_MAX_PDU_SIZE >= (size_t)BLOCK_SIZE(size) + optionLen)
                 {
@@ -1932,6 +1932,10 @@ uint8_t CACheckBlockErrorType(CABlockData_t *currData, coap_block_t *receivedBlo
                     currData->block1.szx = size;
                     break;
                 }
+                if (0 == size)
+                {
+                    break;
+                }
             }
             return CA_BLOCK_TOO_LARGE;
         }