summaryrefslogtreecommitdiff
path: root/tinyusb/common
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-10-02 14:20:05 +0700
committerhathach <[email protected]>2013-10-02 14:20:05 +0700
commit6f9172c15f1c2447549f3004f849261aa580d4f9 (patch)
tree1565fa8c0f570ec02e541805aa5e0cf0fa8eaf7e /tinyusb/common
parent1263dbb1221fc550737e560c415857829e8ecfd1 (diff)
clean up warnings here and there
Diffstat (limited to 'tinyusb/common')
-rw-r--r--tinyusb/common/common.h20
-rw-r--r--tinyusb/common/errors.c2
-rw-r--r--tinyusb/common/errors.h2
3 files changed, 12 insertions, 12 deletions
diff --git a/tinyusb/common/common.h b/tinyusb/common/common.h
index 73de8bce6..e5c72ba7c 100644
--- a/tinyusb/common/common.h
+++ b/tinyusb/common/common.h
@@ -99,17 +99,17 @@
//--------------------------------------------------------------------+
// INLINE FUNCTION
//--------------------------------------------------------------------+
-#define memclr_(buffer, size) memset(buffer, 0, size)
+#define memclr_(buffer, size) memset((buffer), 0, (size))
-static inline uint8_t const * descriptor_next(uint8_t const * p_desc) ATTR_ALWAYS_INLINE ATTR_PURE;
-static inline uint8_t const * descriptor_next(uint8_t const * p_desc)
+static inline uint8_t const * descriptor_next(uint8_t const p_desc[]) ATTR_ALWAYS_INLINE ATTR_PURE;
+static inline uint8_t const * descriptor_next(uint8_t const p_desc[])
{
return p_desc + p_desc[DESCRIPTOR_OFFSET_LENGTH];
}
-static inline uint8_t descriptor_typeof(uint8_t const * p_desc) ATTR_ALWAYS_INLINE ATTR_PURE;
-static inline uint8_t descriptor_typeof(uint8_t const * p_desc)
+static inline uint8_t descriptor_typeof(uint8_t const p_desc[]) ATTR_ALWAYS_INLINE ATTR_PURE;
+static inline uint8_t descriptor_typeof(uint8_t const p_desc[])
{
return p_desc[DESCRIPTOR_OFFSET_TYPE];
}
@@ -119,13 +119,13 @@ static inline uint8_t descriptor_typeof(uint8_t const * p_desc)
static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4) ATTR_ALWAYS_INLINE ATTR_CONST;
static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4)
{
- return (b1 << 24) + (b2 << 16) + (b3 << 8) + b4;
+ return ( ((uint32_t) b1) << 24) + ( ((uint32_t) b2) << 16) + ( ((uint32_t) b3) << 8) + b4;
}
static inline uint8_t u16_high_u8(uint16_t u16) ATTR_CONST ATTR_ALWAYS_INLINE;
static inline uint8_t u16_high_u8(uint16_t u16)
{
- return (uint8_t) ((u16 >> 8) & 0x00ff);
+ return (uint8_t) ( ((uint16_t) (u16 >> 8)) & 0x00ff);
}
static inline uint8_t u16_low_u8(uint16_t u16) ATTR_CONST ATTR_ALWAYS_INLINE;
@@ -137,7 +137,7 @@ static inline uint8_t u16_low_u8(uint16_t u16)
static inline uint16_t u16_le2be(uint16_t u16) ATTR_CONST ATTR_ALWAYS_INLINE;
static inline uint16_t u16_le2be(uint16_t u16)
{
- return (u16_low_u8(u16) << 8) | u16_high_u8(u16);
+ return ((uint16_t)(u16_low_u8(u16) << 8)) | u16_high_u8(u16);
}
//------------- Min -------------//
@@ -182,7 +182,7 @@ static inline uint32_t align16 (uint32_t value)
static inline uint32_t align_n (uint32_t alignment, uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
static inline uint32_t align_n (uint32_t alignment, uint32_t value)
{
- return value & (~(alignment-1));
+ return value & ((uint32_t) ~(alignment-1));
}
static inline uint32_t align4k (uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
@@ -212,7 +212,7 @@ static inline bool is_in_range_exclusive(uint32_t lower, uint32_t value, uint32_
return (lower < value) && (value < upper);
}
-
+// TODO use clz
static inline uint8_t log2_of(uint32_t value) ATTR_ALWAYS_INLINE ATTR_CONST;
static inline uint8_t log2_of(uint32_t value)
{
diff --git a/tinyusb/common/errors.c b/tinyusb/common/errors.c
index b575f0ffa..782d7be94 100644
--- a/tinyusb/common/errors.c
+++ b/tinyusb/common/errors.c
@@ -40,7 +40,7 @@
#if TUSB_CFG_DEBUG == 3
-char const* const TUSB_ErrorStr[] =
+char const* const TUSB_ErrorStr[TUSB_ERROR_COUNT] =
{
ERROR_TABLE(ERROR_STRING)
0
diff --git a/tinyusb/common/errors.h b/tinyusb/common/errors.h
index 8762bf06d..027f9bb2d 100644
--- a/tinyusb/common/errors.h
+++ b/tinyusb/common/errors.h
@@ -104,7 +104,7 @@ typedef enum {
#if TUSB_CFG_DEBUG == 3
/// Enum to String for debugging purposes. Only available if \ref TUSB_CFG_DEBUG > 0
-extern char const* const TUSB_ErrorStr[];
+extern char const* const TUSB_ErrorStr[TUSB_ERROR_COUNT];
#endif
#ifdef __cplusplus