Skip to content

Commit

Permalink
Fix compiler warnings (clwi#13)
Browse files Browse the repository at this point in the history
* fix warning: trailing comma is nonstandard

* fix compiler warning: statement not reachable

* fix compiler warnings: type mismatch (enum <> int)

Co-authored-by: Claes Wihlborg <[email protected]>
  • Loading branch information
Mike8 and clwi authored Feb 10, 2021
1 parent cebee43 commit e547f67
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
8 changes: 3 additions & 5 deletions src/cwpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ void cw_unpack_next (cw_unpack_context* unpack_context)
cw_unpack_assert_blob(bin);
case 0xc7: getDDItem1(CWP_ITEM_EXT, ext.length, uint8_t); // ext 8
cw_unpack_assert_space(1);
unpack_context->item.type = *(int8_t*)p;
unpack_context->item.type = (cwpack_item_types)*(int8_t*)p;
if (unpack_context->item.type == CWP_ITEM_TIMESTAMP)
{
if (unpack_context->item.as.ext.length == 12)
Expand All @@ -537,11 +537,11 @@ void cw_unpack_next (cw_unpack_context* unpack_context)
cw_unpack_assert_blob(ext);
case 0xc8: getDDItem2(CWP_ITEM_EXT, ext.length, uint16_t); // ext 16
cw_unpack_assert_space(1);
unpack_context->item.type = *(int8_t*)p;
unpack_context->item.type = (cwpack_item_types)*(int8_t*)p;
cw_unpack_assert_blob(ext);
case 0xc9: getDDItem4(CWP_ITEM_EXT, ext.length, uint32_t); // ext 32
cw_unpack_assert_space(1);
unpack_context->item.type = *(int8_t*)p;
unpack_context->item.type = (cwpack_item_types)*(int8_t*)p;
cw_unpack_assert_blob(ext);
case 0xca: unpack_context->item.type = CWP_ITEM_FLOAT; // float
cw_unpack_assert_space(4);
Expand Down Expand Up @@ -591,8 +591,6 @@ void cw_unpack_next (cw_unpack_context* unpack_context)
default:
UNPACK_ERROR(CWP_RC_MALFORMED_INPUT)
}

return;
}

#define cw_skip_bytes(n) \
Expand Down
2 changes: 1 addition & 1 deletion src/cwpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ typedef enum
CWP_ITEM_ARRAY = 308,
CWP_ITEM_MAP = 309,
CWP_ITEM_EXT = 310,
CWP_NOT_AN_ITEM = 999,
CWP_NOT_AN_ITEM = 999
} cwpack_item_types;


Expand Down
11 changes: 7 additions & 4 deletions src/cwpack_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@

#define getDDItemFix(len) \
cw_unpack_assert_space(len+1); \
unpack_context->item.type = *(int8_t*)p++; \
if (unpack_context->item.type == CWP_ITEM_TIMESTAMP) \
unpack_context->item.type = (cwpack_item_types)*(int8_t*)p++; \
if (unpack_context->item.type == CWP_ITEM_TIMESTAMP) \
{ \
if (len == 4) \
{ \
Expand All @@ -347,14 +347,17 @@
unpack_context->item.as.time.tv_nsec = 0; \
return; \
} \
if (len == 8) \
else if (len == 8) \
{ \
cw_load64(p,tmpu64); \
unpack_context->item.as.time.tv_sec = tmpu64 & 0x00000003ffffffffL; \
unpack_context->item.as.time.tv_nsec = tmpu64 >> 34; \
return; \
} \
UNPACK_ERROR(CWP_RC_WRONG_TIMESTAMP_LENGTH) \
else \
{ \
UNPACK_ERROR(CWP_RC_WRONG_TIMESTAMP_LENGTH) \
} \
} \
unpack_context->item.as.ext.length = len; \
unpack_context->item.as.ext.start = p; \
Expand Down

0 comments on commit e547f67

Please sign in to comment.