Skip to content

Commit 9e236f3

Browse files
committed
bprintf: use uint32_t instead of int
1 parent fdf21ba commit 9e236f3

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

uprintf.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,9 @@ struct _upf_state {
606606
_upf_range_vec addresses;
607607
// bprintf
608608
char *buffer;
609-
int size;
610609
char *ptr;
611-
int free;
610+
uint32_t size;
611+
uint32_t free;
612612
// error handling
613613
jmp_buf jmp_buf;
614614
const char *file_path;
@@ -1731,7 +1731,6 @@ static _upf_range_vec _upf_get_ranges(const _upf_cu *cu, const uint8_t *die, uin
17311731
return ranges;
17321732
}
17331733
}
1734-
17351734
return ranges;
17361735
}
17371736

@@ -2960,8 +2959,8 @@ static const void *_upf_get_memory_region_end(const void *ptr) {
29602959
while (true) { \
29612960
int bytes = snprintf(_upf_state.ptr, _upf_state.free, __VA_ARGS__); \
29622961
if (bytes < 0) _UPF_ERROR("Unexpected error occurred in snprintf: %s.", strerror(errno)); \
2963-
if (bytes >= _upf_state.free) { \
2964-
int used = _upf_state.size - _upf_state.free; \
2962+
if ((uint32_t) bytes >= _upf_state.free) { \
2963+
uint32_t used = _upf_state.size - _upf_state.free; \
29652964
_upf_state.size *= 2; \
29662965
_upf_state.buffer = (char *) realloc(_upf_state.buffer, _upf_state.size); \
29672966
if (_upf_state.buffer == NULL) _UPF_OUT_OF_MEMORY(); \

0 commit comments

Comments
 (0)