Skip to content

Commit

Permalink
address lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TingDaoK committed Jul 27, 2023
1 parent dbad251 commit 144c075
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 33 deletions.
2 changes: 1 addition & 1 deletion include/aws/common/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct aws_allocator *aws_default_allocator(void);

#ifdef __MACH__
/* Avoid pulling in CoreFoundation headers in a header file. */
struct __CFAllocator;
struct __CFAllocator; /* NOLINT */
typedef const struct __CFAllocator *CFAllocatorRef;

/**
Expand Down
2 changes: 1 addition & 1 deletion include/aws/common/array_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

AWS_PUSH_SANE_WARNING_LEVEL

#define AWS_ARRAY_LIST_DEBUG_FILL 0xDD
enum { AWS_ARRAY_LIST_DEBUG_FILL = 0xDD };

struct aws_array_list {
struct aws_allocator *alloc;
Expand Down
3 changes: 1 addition & 2 deletions include/aws/common/date_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

AWS_PUSH_SANE_WARNING_LEVEL

#define AWS_DATE_TIME_STR_MAX_LEN 100
#define AWS_DATE_TIME_STR_MAX_BASIC_LEN 20
enum { AWS_DATE_TIME_STR_MAX_LEN = 100, AWS_DATE_TIME_STR_MAX_BASIC_LEN = 20 };

struct aws_byte_buf;
struct aws_byte_cursor;
Expand Down
8 changes: 5 additions & 3 deletions include/aws/common/hash_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@

AWS_PUSH_SANE_WARNING_LEVEL

#define AWS_COMMON_HASH_TABLE_ITER_CONTINUE (1 << 0)
#define AWS_COMMON_HASH_TABLE_ITER_DELETE (1 << 1)
#define AWS_COMMON_HASH_TABLE_ITER_ERROR (1 << 2)
enum {
AWS_COMMON_HASH_TABLE_ITER_CONTINUE = (1 << 0),
AWS_COMMON_HASH_TABLE_ITER_DELETE = (1 << 1),
AWS_COMMON_HASH_TABLE_ITER_ERROR = (1 << 2),
};

/**
* Hash table data structure. This module provides an automatically resizing
Expand Down
6 changes: 4 additions & 2 deletions include/aws/common/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ enum aws_log_level {
typedef uint32_t aws_log_subject_t;

/* Each library gets space for 2^^10 log subject entries */
#define AWS_LOG_SUBJECT_STRIDE_BITS 10
#define AWS_LOG_SUBJECT_STRIDE (1U << AWS_LOG_SUBJECT_STRIDE_BITS)
enum {
AWS_LOG_SUBJECT_STRIDE_BITS = 10,
AWS_LOG_SUBJECT_STRIDE = (1U << AWS_LOG_SUBJECT_STRIDE_BITS),
};
#define AWS_LOG_SUBJECT_BEGIN_RANGE(x) ((x)*AWS_LOG_SUBJECT_STRIDE)
#define AWS_LOG_SUBJECT_END_RANGE(x) (((x) + 1) * AWS_LOG_SUBJECT_STRIDE - 1)

Expand Down
2 changes: 1 addition & 1 deletion include/aws/common/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ AWS_STATIC_ASSERT(CALL_OVERLOAD_TEST(1) == 1);
AWS_STATIC_ASSERT(CALL_OVERLOAD_TEST(1, 2) == 2);
AWS_STATIC_ASSERT(CALL_OVERLOAD_TEST(1, 2, 3) == 3);

#define AWS_CACHE_LINE 64
enum { AWS_CACHE_LINE = 64 };
/**
* Format macro for strings of a specified length.
* Allows non null-terminated strings to be used with the printf family of functions.
Expand Down
6 changes: 4 additions & 2 deletions include/aws/common/statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ struct aws_array_list;
typedef uint32_t aws_crt_statistics_category_t;

/* Each library gets space for 2^^8 category entries */
#define AWS_CRT_STATISTICS_CATEGORY_STRIDE_BITS 8
#define AWS_CRT_STATISTICS_CATEGORY_STRIDE (1U << AWS_CRT_STATISTICS_CATEGORY_STRIDE_BITS)
enum {
AWS_CRT_STATISTICS_CATEGORY_STRIDE_BITS = 8,
AWS_CRT_STATISTICS_CATEGORY_STRIDE = (1U << AWS_CRT_STATISTICS_CATEGORY_STRIDE_BITS)
};
#define AWS_CRT_STATISTICS_CATEGORY_BEGIN_RANGE(x) ((x)*AWS_CRT_STATISTICS_CATEGORY_STRIDE)
#define AWS_CRT_STATISTICS_CATEGORY_END_RANGE(x) (((x) + 1) * AWS_CRT_STATISTICS_CATEGORY_STRIDE - 1)

Expand Down
2 changes: 1 addition & 1 deletion include/aws/common/uuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct aws_uuid {
};

/* 36 bytes for the UUID plus one more for the null terminator. */
#define AWS_UUID_STR_LEN 37
enum { AWS_UUID_STR_LEN = 37 };

AWS_EXTERN_C_BEGIN

Expand Down
2 changes: 1 addition & 1 deletion source/allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ static void *s_cf_allocator_reallocate(void *ptr, CFIndex new_size, CFOptionFlag
aws_mem_realloc(allocator, &original_allocation, original_size, (size_t)new_size);

size_t new_allocation_size = (size_t)new_size;
memcpy(original_allocation, &new_allocation_size, sizeof(size_t));
memcpy(original_allocation, &new_allocation_size, sizeof(size_t)); /* NOLINT */

return (void *)((uint8_t *)original_allocation + sizeof(size_t));
}
Expand Down
2 changes: 1 addition & 1 deletion source/allocator_sba.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#define AWS_SBA_TAG_VALUE 0x736f6d6570736575ULL

/* list of sizes of bins, must be powers of 2, and less than AWS_SBA_PAGE_SIZE * 0.5 */
#define AWS_SBA_BIN_COUNT 5
enum { AWS_SBA_BIN_COUNT = 5 };
static const size_t s_bin_sizes[AWS_SBA_BIN_COUNT] = {32, 64, 128, 256, 512};
static const size_t s_max_bin_size = 512;

Expand Down
2 changes: 1 addition & 1 deletion source/hash_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ uint64_t aws_hash_byte_cursor_ptr(const void *item) {
/* first digits of pi in hex */
uint32_t b = 0x3243F6A8, c = 0x885A308D;
hashlittle2(cur->ptr, cur->len, &c, &b);
AWS_RETURN_WITH_POSTCONDITION(((uint64_t)b << 32) | c, aws_byte_cursor_is_valid(cur));
AWS_RETURN_WITH_POSTCONDITION(((uint64_t)b << 32) | c, aws_byte_cursor_is_valid(cur)); /* NOLINT */
}

uint64_t aws_hash_ptr(const void *item) {
Expand Down
16 changes: 9 additions & 7 deletions source/log_formatter.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@
# pragma warning(disable : 4204) /* non-constant aggregate initializer */
#endif

/* (max) strlen of "[<LogLevel>]" */
#define LOG_LEVEL_PREFIX_PADDING 7
enum {
/* (max) strlen of "[<LogLevel>]" */
LOG_LEVEL_PREFIX_PADDING = 7,

/* (max) strlen of "[<ThreadId>]" */
#define THREAD_ID_PREFIX_PADDING 22
/* (max) strlen of "[<ThreadId>]" */
THREAD_ID_PREFIX_PADDING = 22,

/* strlen of (user-content separator) " - " + "\n" + spaces between prefix fields + brackets around timestamp + 1 +
subject_name padding */
#define MISC_PADDING 15
/* strlen of (user-content separator) " - " + "\n" + spaces between prefix fields + brackets around timestamp + 1 +
subject_name padding */
MISC_PADDING = 15,
};

#define MAX_LOG_LINE_PREFIX_SIZE \
(LOG_LEVEL_PREFIX_PADDING + THREAD_ID_PREFIX_PADDING + MISC_PADDING + AWS_DATE_TIME_STR_MAX_LEN)
Expand Down
2 changes: 1 addition & 1 deletion source/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ static enum aws_log_level s_noalloc_stderr_logger_get_log_level(struct aws_logge
return (enum aws_log_level)aws_atomic_load_int(&impl->level);
}

#define MAXIMUM_NO_ALLOC_LOG_LINE_SIZE 8192
enum { MAXIMUM_NO_ALLOC_LOG_LINE_SIZE = 8192 };

static int s_noalloc_stderr_logger_log(
struct aws_logger *logger,
Expand Down
2 changes: 1 addition & 1 deletion source/memtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct alloc_tracer {
};

/* number of frames to skip in call stacks (s_alloc_tracer_track, and the vtable function) */
#define FRAMES_TO_SKIP 2
enum { FRAMES_TO_SKIP = 2 };

static void *s_trace_mem_acquire(struct aws_allocator *allocator, size_t size);
static void s_trace_mem_release(struct aws_allocator *allocator, void *ptr);
Expand Down
4 changes: 2 additions & 2 deletions source/posix/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ static int s_legacy_get_time(uint64_t *timestamp) {

# if MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
static aws_thread_once s_thread_once_flag = AWS_THREAD_ONCE_STATIC_INIT;
static int (*s_gettime_fn)(clockid_t __clock_id, struct timespec *__tp) = NULL;
static int (*s_gettime_fn)(clockid_t clock_id, struct timespec *tp) = NULL;

static void s_do_osx_loads(void *user_data) {
(void)user_data;
s_gettime_fn = (int (*)(clockid_t __clock_id, struct timespec * __tp)) dlsym(RTLD_DEFAULT, "clock_gettime");
s_gettime_fn = (int (*)(clockid_t clock_id, struct timespec * tp)) dlsym(RTLD_DEFAULT, "clock_gettime");
}

int aws_high_res_clock_get_ticks(uint64_t *timestamp) {
Expand Down
3 changes: 2 additions & 1 deletion source/posix/device_random.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ int aws_device_random_buffer_append(struct aws_byte_buf *output, size_t n) {
/* read() can fail if N is too large (e.g. x64 macos fails if N > INT32_MAX),
* so work in reasonably sized chunks. */
while (n > 0) {
size_t capped_n = aws_min_size(n, 1024 * 1024 * 1024 * 1 /* 1GiB */);
size_t capped_n = aws_min_size(
n, 1024 * 1024 * 1024 * 1 /* 1GiB */); /* NOLINT(bugprone-implicit-widening-of-multiplication-result) */

ssize_t amount_read = read(s_rand_fd, output->buffer + output->len, capped_n);

Expand Down
8 changes: 5 additions & 3 deletions source/posix/mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ int aws_mutex_init(struct aws_mutex *mutex) {
int return_code = AWS_OP_SUCCESS;

if (!err_code) {
if ((err_code = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL)) ||
(err_code = pthread_mutex_init(&mutex->mutex_handle, &attr))) {

err_code = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
if (!err_code) {
err_code = pthread_mutex_init(&mutex->mutex_handle, &attr);
}
if (err_code) {
return_code = aws_private_convert_and_raise_error_code(err_code);
}
pthread_mutexattr_destroy(&attr);
Expand Down
2 changes: 1 addition & 1 deletion source/posix/system_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ int s_parse_symbol(const char *symbol, void *addr, struct aws_stack_frame_info *
if (function_len >= (sizeof(frame->function) - 1)) {
function_len = sizeof(frame->function) - 1;
}
strncpy(frame->function, function_start, function_end - function_start);
strncpy(frame->function, function_start, function_len);

/* find base addr for library/exe */
Dl_info addr_info;
Expand Down
2 changes: 1 addition & 1 deletion source/process_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <stdio.h>
#include <sys/types.h>

#define MAX_BUFFER_SIZE (2048)
enum { MAX_BUFFER_SIZE = 2048 };

int aws_run_command_result_init(struct aws_allocator *allocator, struct aws_run_command_result *result) {
if (!allocator || !result) {
Expand Down

0 comments on commit 144c075

Please sign in to comment.