Skip to content

Commit 4090d10

Browse files
ColdenCullenJonathanHenson
authored andcommitted
Convert column widths to 120 and reformat (awslabs#102)
It's just styling, merging it over.
1 parent 6e0e013 commit 4090d10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1292
-3190
lines changed

.clang-format

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ BreakBeforeBinaryOperators: None
2121
BreakBeforeBraces: Attach
2222
BreakBeforeTernaryOperators: true
2323
BreakStringLiterals: true
24-
ColumnLimit: 80
24+
ColumnLimit: 120
2525
ContinuationIndentWidth: 4
2626
DerivePointerAlignment: false
2727
IncludeBlocks: Preserve

include/aws/common/array_list.h

+7-26
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ int aws_array_list_init_dynamic(
6060
* is full, new items will be rejected.
6161
*/
6262
AWS_COMMON_API
63-
void aws_array_list_init_static(
64-
struct aws_array_list *list,
65-
void *raw_array,
66-
size_t item_count,
67-
size_t item_size);
63+
void aws_array_list_init_static(struct aws_array_list *list, void *raw_array, size_t item_count, size_t item_size);
6864

6965
/**
7066
* Deallocates any memory that was allocated for this list, and resets list for
@@ -138,18 +134,14 @@ int aws_array_list_shrink_to_fit(struct aws_array_list *list);
138134
* copy.
139135
*/
140136
AWS_COMMON_API
141-
int aws_array_list_copy(
142-
const struct aws_array_list *from,
143-
struct aws_array_list *to);
137+
int aws_array_list_copy(const struct aws_array_list *from, struct aws_array_list *to);
144138

145139
/**
146140
* Swap contents between two dynamic lists. Both lists must use the same
147141
* allocator.
148142
*/
149143
AWS_COMMON_API
150-
void aws_array_list_swap_contents(
151-
struct aws_array_list *list_a,
152-
struct aws_array_list *list_b);
144+
void aws_array_list_swap_contents(struct aws_array_list *list_a, struct aws_array_list *list_b);
153145

154146
/**
155147
* Returns the number of elements that can fit in the internal array. If list is
@@ -169,20 +161,14 @@ size_t aws_array_list_length(const struct aws_array_list *list);
169161
* AWS_ERROR_INVALID_INDEX will be raised.
170162
*/
171163
AWS_COMMON_API
172-
int aws_array_list_get_at(
173-
const struct aws_array_list *list,
174-
void *val,
175-
size_t index);
164+
int aws_array_list_get_at(const struct aws_array_list *list, void *val, size_t index);
176165

177166
/**
178167
* Copies the memory address of the element at index to *val. If element does
179168
* not exist, AWS_ERROR_INVALID_INDEX will be raised.
180169
*/
181170
AWS_COMMON_API
182-
int aws_array_list_get_at_ptr(
183-
const struct aws_array_list *list,
184-
void **val,
185-
size_t index);
171+
int aws_array_list_get_at_ptr(const struct aws_array_list *list, void **val, size_t index);
186172

187173
/**
188174
* Copies the the memory pointed to by val into the array at index. If in
@@ -191,10 +177,7 @@ int aws_array_list_get_at_ptr(
191177
* the bounds of the array.
192178
*/
193179
AWS_COMMON_API
194-
int aws_array_list_set_at(
195-
struct aws_array_list *list,
196-
const void *val,
197-
size_t index);
180+
int aws_array_list_set_at(struct aws_array_list *list, const void *val, size_t index);
198181

199182
/**
200183
* Swap elements at the specified indices.
@@ -206,9 +189,7 @@ void aws_array_list_swap(struct aws_array_list *list, size_t a, size_t b);
206189
* Sort elements in the list in-place according to the comparator function.
207190
*/
208191
AWS_COMMON_API
209-
void aws_array_list_sort(
210-
struct aws_array_list *list,
211-
aws_array_list_comparator compare_fn);
192+
void aws_array_list_sort(struct aws_array_list *list, aws_array_list_comparator compare_fn);
212193

213194
#ifdef __cplusplus
214195
}

include/aws/common/byte_buf.h

+19-54
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ extern "C" {
5050
#endif
5151

5252
AWS_COMMON_API
53-
int aws_byte_buf_init(
54-
struct aws_allocator *allocator,
55-
struct aws_byte_buf *buf,
56-
size_t len);
53+
int aws_byte_buf_init(struct aws_allocator *allocator, struct aws_byte_buf *buf, size_t len);
54+
5755
AWS_COMMON_API
5856
void aws_byte_buf_clean_up(struct aws_byte_buf *buf);
5957

@@ -90,10 +88,7 @@ AWS_COMMON_API void aws_byte_buf_secure_clean_up(struct aws_byte_buf *buf);
9088
* long enough to use the results.
9189
*/
9290
AWS_COMMON_API
93-
int aws_byte_buf_split_on_char(
94-
struct aws_byte_buf *input_str,
95-
char split_on,
96-
struct aws_array_list *output);
91+
int aws_byte_buf_split_on_char(struct aws_byte_buf *input_str, char split_on, struct aws_array_list *output);
9792

9893
/**
9994
* No copies, no buffer allocations. Fills in output with a list of
@@ -156,9 +151,7 @@ static inline struct aws_byte_buf aws_byte_buf_from_c_str(const char *c_str) {
156151
return buf;
157152
}
158153

159-
static inline struct aws_byte_buf aws_byte_buf_from_array(
160-
const uint8_t *bytes,
161-
size_t len) {
154+
static inline struct aws_byte_buf aws_byte_buf_from_array(const uint8_t *bytes, size_t len) {
162155
struct aws_byte_buf buf;
163156
buf.buffer = (uint8_t *)bytes;
164157
buf.len = len;
@@ -167,17 +160,14 @@ static inline struct aws_byte_buf aws_byte_buf_from_array(
167160
return buf;
168161
}
169162

170-
static inline struct aws_byte_cursor aws_byte_cursor_from_buf(
171-
const struct aws_byte_buf *buf) {
163+
static inline struct aws_byte_cursor aws_byte_cursor_from_buf(const struct aws_byte_buf *buf) {
172164
struct aws_byte_cursor cur;
173165
cur.ptr = buf->buffer;
174166
cur.len = buf->len;
175167
return cur;
176168
}
177169

178-
static inline struct aws_byte_cursor aws_byte_cursor_from_array(
179-
const void *bytes,
180-
size_t len) {
170+
static inline struct aws_byte_cursor aws_byte_cursor_from_array(const void *bytes, size_t len) {
181171
struct aws_byte_cursor cur;
182172
cur.ptr = (uint8_t *)bytes;
183173
cur.len = len;
@@ -259,12 +249,9 @@ static inline size_t aws_nospec_index(size_t index, size_t bound) {
259249
* Note that if len is above (SIZE_MAX / 2), this function will also treat it as
260250
* a buffer overflow, and return NULL without changing *buf.
261251
*/
262-
static inline struct aws_byte_cursor aws_byte_cursor_advance(
263-
struct aws_byte_cursor *cursor,
264-
size_t len) {
252+
static inline struct aws_byte_cursor aws_byte_cursor_advance(struct aws_byte_cursor *cursor, size_t len) {
265253
struct aws_byte_cursor rv;
266-
if (cursor->len > (SIZE_MAX >> 1) || len > (SIZE_MAX >> 1) ||
267-
len > cursor->len) {
254+
if (cursor->len > (SIZE_MAX >> 1) || len > (SIZE_MAX >> 1) || len > cursor->len) {
268255
rv.ptr = NULL;
269256
rv.len = 0;
270257
} else {
@@ -288,13 +275,10 @@ static inline struct aws_byte_cursor aws_byte_cursor_advance(
288275
* cursor->ptr points outside the true ptr length.
289276
*/
290277

291-
static inline struct aws_byte_cursor aws_byte_cursor_advance_nospec(
292-
struct aws_byte_cursor *cursor,
293-
size_t len) {
278+
static inline struct aws_byte_cursor aws_byte_cursor_advance_nospec(struct aws_byte_cursor *cursor, size_t len) {
294279
struct aws_byte_cursor rv;
295280

296-
if (len <= cursor->len && len <= (SIZE_MAX >> 1) &&
297-
cursor->len <= (SIZE_MAX >> 1)) {
281+
if (len <= cursor->len && len <= (SIZE_MAX >> 1) && cursor->len <= (SIZE_MAX >> 1)) {
298282
/*
299283
* Pass the length through aws_nospec_index. We do this after the
300284
* branch, as otherwise we'd treat an out-of-bounds read as a
@@ -323,10 +307,7 @@ static inline struct aws_byte_cursor aws_byte_cursor_advance_nospec(
323307
* If there is insufficient space in the cursor, returns false, leaving the
324308
* cursor unchanged.
325309
*/
326-
static inline bool aws_byte_cursor_read(
327-
struct aws_byte_cursor *AWS_RESTRICT cur,
328-
void *AWS_RESTRICT dest,
329-
size_t len) {
310+
static inline bool aws_byte_cursor_read(struct aws_byte_cursor *AWS_RESTRICT cur, void *AWS_RESTRICT dest, size_t len) {
330311
struct aws_byte_cursor slice = aws_byte_cursor_advance_nospec(cur, len);
331312

332313
if (slice.ptr) {
@@ -360,9 +341,7 @@ static inline bool aws_byte_cursor_read_and_fill_buffer(
360341
* If there is insufficient space in the cursor, returns false, leaving the
361342
* cursor unchanged.
362343
*/
363-
static inline bool aws_byte_cursor_read_u8(
364-
struct aws_byte_cursor *AWS_RESTRICT cur,
365-
uint8_t *AWS_RESTRICT var) {
344+
static inline bool aws_byte_cursor_read_u8(struct aws_byte_cursor *AWS_RESTRICT cur, uint8_t *AWS_RESTRICT var) {
366345
return aws_byte_cursor_read(cur, var, 1);
367346
}
368347

@@ -374,9 +353,7 @@ static inline bool aws_byte_cursor_read_u8(
374353
* If there is insufficient space in the cursor, returns false, leaving the
375354
* cursor unchanged.
376355
*/
377-
static inline bool aws_byte_cursor_read_be16(
378-
struct aws_byte_cursor *cur,
379-
uint16_t *var) {
356+
static inline bool aws_byte_cursor_read_be16(struct aws_byte_cursor *cur, uint16_t *var) {
380357
bool rv = aws_byte_cursor_read(cur, var, 2);
381358

382359
if (AWS_LIKELY(rv)) {
@@ -394,9 +371,7 @@ static inline bool aws_byte_cursor_read_be16(
394371
* If there is insufficient space in the cursor, returns false, leaving the
395372
* cursor unchanged.
396373
*/
397-
static inline bool aws_byte_cursor_read_be32(
398-
struct aws_byte_cursor *cur,
399-
uint32_t *var) {
374+
static inline bool aws_byte_cursor_read_be32(struct aws_byte_cursor *cur, uint32_t *var) {
400375
bool rv = aws_byte_cursor_read(cur, var, 4);
401376

402377
if (AWS_LIKELY(rv)) {
@@ -414,9 +389,7 @@ static inline bool aws_byte_cursor_read_be32(
414389
* If there is insufficient space in the cursor, returns false, leaving the
415390
* cursor unchanged.
416391
*/
417-
static inline bool aws_byte_cursor_read_be64(
418-
struct aws_byte_cursor *cur,
419-
uint64_t *var) {
392+
static inline bool aws_byte_cursor_read_be64(struct aws_byte_cursor *cur, uint64_t *var) {
420393
bool rv = aws_byte_cursor_read(cur, var, sizeof(*var));
421394

422395
if (AWS_LIKELY(rv)) {
@@ -468,9 +441,7 @@ static inline bool aws_byte_cursor_write_from_whole_buffer(
468441
* If there is insufficient space in the cursor, returns false, leaving the
469442
cursor unchanged.
470443
*/
471-
static inline bool aws_byte_cursor_write_u8(
472-
struct aws_byte_cursor *AWS_RESTRICT cur,
473-
uint8_t c) {
444+
static inline bool aws_byte_cursor_write_u8(struct aws_byte_cursor *AWS_RESTRICT cur, uint8_t c) {
474445
return aws_byte_cursor_write(cur, &c, 1);
475446
}
476447

@@ -481,9 +452,7 @@ static inline bool aws_byte_cursor_write_u8(
481452
* If there is insufficient space in the cursor, returns false, leaving the
482453
* cursor unchanged.
483454
*/
484-
static inline bool aws_byte_cursor_write_be16(
485-
struct aws_byte_cursor *cur,
486-
uint16_t x) {
455+
static inline bool aws_byte_cursor_write_be16(struct aws_byte_cursor *cur, uint16_t x) {
487456
x = aws_hton16(x);
488457
return aws_byte_cursor_write(cur, (uint8_t *)&x, 2);
489458
}
@@ -495,9 +464,7 @@ static inline bool aws_byte_cursor_write_be16(
495464
* If there is insufficient space in the cursor, returns false, leaving the
496465
* cursor unchanged.
497466
*/
498-
static inline bool aws_byte_cursor_write_be32(
499-
struct aws_byte_cursor *cur,
500-
uint32_t x) {
467+
static inline bool aws_byte_cursor_write_be32(struct aws_byte_cursor *cur, uint32_t x) {
501468
x = aws_hton32(x);
502469
return aws_byte_cursor_write(cur, (uint8_t *)&x, 4);
503470
}
@@ -509,9 +476,7 @@ static inline bool aws_byte_cursor_write_be32(
509476
* If there is insufficient space in the cursor, returns false, leaving the
510477
* cursor unchanged.
511478
*/
512-
static inline bool aws_byte_cursor_write_be64(
513-
struct aws_byte_cursor *cur,
514-
uint64_t x) {
479+
static inline bool aws_byte_cursor_write_be64(struct aws_byte_cursor *cur, uint64_t x) {
515480
x = aws_hton64(x);
516481
return aws_byte_cursor_write(cur, (uint8_t *)&x, 8);
517482
}

include/aws/common/common.h

+19-31
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121
#include <stddef.h>
2222
#include <string.h>
2323

24-
#define AWS_STATIC_ASSERT0(cond, msg) \
25-
typedef char static_assertion_##msg[(!!(cond)) * 2 - 1]
26-
#define AWS_STATIC_ASSERT1(cond, line) \
27-
AWS_STATIC_ASSERT0(cond, static_assertion_at_line_##line)
24+
#define AWS_STATIC_ASSERT0(cond, msg) typedef char static_assertion_##msg[(!!(cond)) * 2 - 1]
25+
#define AWS_STATIC_ASSERT1(cond, line) AWS_STATIC_ASSERT0(cond, static_assertion_at_line_##line)
2826
#define AWS_STATIC_ASSERT(cond) AWS_STATIC_ASSERT1(cond, __LINE__)
2927

3028
#if defined(_MSC_VER)
@@ -53,8 +51,7 @@
5351
#ifndef NO_STDINT
5452
# include <stdint.h> /* NOLINT(fuchsia-restrict-system-includes) */
5553
#else
56-
# if defined(__x86_64__) || defined(_M_AMD64) || \
57-
defined(__aarch64__) || defined(__ia64__) || \
54+
# if defined(__x86_64__) || defined(_M_AMD64) || defined(__aarch64__) || defined(__ia64__) || \
5855
defined(__powerpc64__)
5956
# define PTR_SIZE 8
6057
# else
@@ -138,11 +135,7 @@ struct aws_allocator {
138135
void *(*mem_acquire)(struct aws_allocator *allocator, size_t size);
139136
void (*mem_release)(struct aws_allocator *allocator, void *ptr);
140137
/* Optional method; if not supported, this pointer must be NULL */
141-
void *(*mem_realloc)(
142-
struct aws_allocator *allocator,
143-
void *oldptr,
144-
size_t oldsize,
145-
size_t newsize);
138+
void *(*mem_realloc)(struct aws_allocator *allocator, void *oldptr, size_t oldsize, size_t newsize);
146139
void *impl;
147140
};
148141

@@ -197,11 +190,7 @@ void aws_mem_release(struct aws_allocator *allocator, void *ptr);
197190
* AWS_ERROR_OOM error.
198191
*/
199192
AWS_COMMON_API
200-
int aws_mem_realloc(
201-
struct aws_allocator *allocator,
202-
void **ptr,
203-
size_t oldsize,
204-
size_t newsize);
193+
int aws_mem_realloc(struct aws_allocator *allocator, void **ptr, size_t oldsize, size_t newsize);
205194
/*
206195
* Maintainer note: The above function doesn't return the pointer (as with
207196
* standard C realloc) as this pattern becomes error-prone when OOMs occur.
@@ -319,21 +308,20 @@ static inline void aws_secure_zero(void *pBuf, size_t bufsize) {
319308
* (somehow) still used after the zero, and therefore that the optimizer
320309
* can't eliminate the memset.
321310
*/
322-
__asm__ __volatile__(
323-
"" /* The asm doesn't actually do anything. */
324-
: /* no outputs */
325-
/* Tell the compiler that the asm code has access to the pointer to the
326-
* buffer, and therefore it might be reading the (now-zeroed) buffer.
327-
* Without this. clang/LLVM 9.0.0 optimizes away a memset of a stack
328-
* buffer.
329-
*/
330-
: "r"(pBuf)
331-
/* Also clobber memory. While this seems like it might be unnecessary -
332-
* after all, it's enough that the asm might read the buffer, right? -
333-
* in practice GCC 7.3.0 seems to optimize a zero of a stack buffer
334-
* without it.
335-
*/
336-
: "memory");
311+
__asm__ __volatile__("" /* The asm doesn't actually do anything. */
312+
: /* no outputs */
313+
/* Tell the compiler that the asm code has access to the pointer to the
314+
* buffer, and therefore it might be reading the (now-zeroed) buffer.
315+
* Without this. clang/LLVM 9.0.0 optimizes away a memset of a stack
316+
* buffer.
317+
*/
318+
: "r"(pBuf)
319+
/* Also clobber memory. While this seems like it might be unnecessary -
320+
* after all, it's enough that the asm might read the buffer, right? -
321+
* in practice GCC 7.3.0 seems to optimize a zero of a stack buffer
322+
* without it.
323+
*/
324+
: "memory");
337325
# else // not GCC/clang
338326
/* We don't have access to inline asm, since we're on a non-GCC platform.
339327
* Move the pointer through a volatile pointer in an attempt to confuse the

0 commit comments

Comments
 (0)