Skip to content

Instantly share code, notes, and snippets.

@thestinger
Created April 9, 2019 04:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thestinger/b2fc46ce9262c5b715a2bffc7648c53f to your computer and use it in GitHub Desktop.
Save thestinger/b2fc46ce9262c5b715a2bffc7648c53f to your computer and use it in GitHub Desktop.
/home/strcat/projects/hardened_malloc/chacha.c:49:14: warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
x->input[5] = U8TO32_LITTLE(k + 4);
^
/home/strcat/projects/hardened_malloc/chacha.c:50:14: warning: 6 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
x->input[6] = U8TO32_LITTLE(k + 8);
^
/home/strcat/projects/hardened_malloc/chacha.c:51:14: warning: 7 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
x->input[7] = U8TO32_LITTLE(k + 12);
^
/home/strcat/projects/hardened_malloc/chacha.c:52:14: warning: 8 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
x->input[8] = U8TO32_LITTLE(k + 16);
^
/home/strcat/projects/hardened_malloc/chacha.c:53:14: warning: 9 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
x->input[9] = U8TO32_LITTLE(k + 20);
^
/home/strcat/projects/hardened_malloc/chacha.c:54:14: warning: 10 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
x->input[10] = U8TO32_LITTLE(k + 24);
^
/home/strcat/projects/hardened_malloc/chacha.c:55:14: warning: 11 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
x->input[11] = U8TO32_LITTLE(k + 28);
^
/home/strcat/projects/hardened_malloc/chacha.c:59:14: warning: 12 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
x->input[12] = 0;
^
/home/strcat/projects/hardened_malloc/chacha.c:60:14: warning: 13 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
x->input[13] = 0;
^
/home/strcat/projects/hardened_malloc/chacha.c:61:14: warning: 14 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
x->input[14] = U8TO32_LITTLE(iv + 0);
^
/home/strcat/projects/hardened_malloc/chacha.c:62:14: warning: 15 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
x->input[15] = U8TO32_LITTLE(iv + 4);
^
/home/strcat/projects/hardened_malloc/chacha.c:71:12: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
u8 tmp[64];
^
/home/strcat/projects/hardened_malloc/chacha.c:78:23: warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
u32 j5 = x->input[5];
^
/home/strcat/projects/hardened_malloc/chacha.c:79:23: warning: 6 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
u32 j6 = x->input[6];
^
/home/strcat/projects/hardened_malloc/chacha.c:80:23: warning: 7 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
u32 j7 = x->input[7];
^
/home/strcat/projects/hardened_malloc/chacha.c:81:23: warning: 8 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
u32 j8 = x->input[8];
^
/home/strcat/projects/hardened_malloc/chacha.c:82:23: warning: 9 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
u32 j9 = x->input[9];
^
/home/strcat/projects/hardened_malloc/chacha.c:83:24: warning: 10 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
u32 j10 = x->input[10];
^
/home/strcat/projects/hardened_malloc/chacha.c:84:24: warning: 11 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
u32 j11 = x->input[11];
^
/home/strcat/projects/hardened_malloc/chacha.c:85:24: warning: 12 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
u32 j12 = x->input[12];
^
/home/strcat/projects/hardened_malloc/chacha.c:86:24: warning: 13 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
u32 j13 = x->input[13];
^
/home/strcat/projects/hardened_malloc/chacha.c:87:24: warning: 14 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
u32 j14 = x->input[14];
^
/home/strcat/projects/hardened_malloc/chacha.c:88:24: warning: 15 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
u32 j15 = x->input[15];
^
/home/strcat/projects/hardened_malloc/chacha.c:91:21: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
if (bytes < 64) {
^
/home/strcat/projects/hardened_malloc/chacha.c:111:27: warning: 8 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
for (unsigned i = 8; i > 0; i -= 2) {
^
/home/strcat/projects/hardened_malloc/chacha.c:161:22: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
if (bytes <= 64) {
^
/home/strcat/projects/hardened_malloc/chacha.c:162:25: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
if (bytes < 64) {
^
/home/strcat/projects/hardened_malloc/chacha.c:167:22: warning: 12 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
x->input[12] = j12;
^
/home/strcat/projects/hardened_malloc/chacha.c:168:22: warning: 13 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
x->input[13] = j13;
^
/home/strcat/projects/hardened_malloc/chacha.c:171:18: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
bytes -= 64;
^
/home/strcat/projects/hardened_malloc/chacha.c:172:14: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
c += 64;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:29:33: warning: 8 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
static_assert(sizeof(void *) == 8, "64-bit only");
^
/home/strcat/projects/hardened_malloc/h_malloc.c:33:86: warning: 65536 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
static_assert(SLAB_QUARANTINE_RANDOM_LENGTH >= 0 && SLAB_QUARANTINE_RANDOM_LENGTH <= 65536,
^
/home/strcat/projects/hardened_malloc/h_malloc.c:35:84: warning: 65536 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
static_assert(SLAB_QUARANTINE_QUEUE_LENGTH >= 0 && SLAB_QUARANTINE_QUEUE_LENGTH <= 65536,
^
/home/strcat/projects/hardened_malloc/h_malloc.c:37:90: warning: 65536 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
static_assert(REGION_QUARANTINE_RANDOM_LENGTH >= 0 && REGION_QUARANTINE_RANDOM_LENGTH <= 65536,
^
/home/strcat/projects/hardened_malloc/h_malloc.c:39:88: warning: 65536 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
static_assert(REGION_QUARANTINE_QUEUE_LENGTH >= 0 && REGION_QUARANTINE_QUEUE_LENGTH <= 65536,
^
/home/strcat/projects/hardened_malloc/h_malloc.c:41:98: warning: 65536 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
static_assert(FREE_SLABS_QUARANTINE_RANDOM_LENGTH >= 0 && FREE_SLABS_QUARANTINE_RANDOM_LENGTH <= 65536,
^
/home/strcat/projects/hardened_malloc/h_malloc.c:154:17: warning: 128 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
if (size <= 128) {
^
/home/strcat/projects/hardened_malloc/h_malloc.c:155:43: warning: 15 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
return (struct size_info){(size + 15) & ~15, ((size - 1) >> 4) + 1};
^
/home/strcat/projects/hardened_malloc/h_malloc.c:155:50: warning: 15 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
return (struct size_info){(size + 15) & ~15, ((size - 1) >> 4) + 1};
^
/home/strcat/projects/hardened_malloc/h_malloc.c:157:27: warning: 9 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
for (unsigned class = 9; class < N_SIZE_CLASSES; class++) {
^
/home/strcat/projects/hardened_malloc/h_malloc.c:157:30: warning: loop variable has narrower type 'unsigned int' than iteration's upper bound 'unsigned long' [bugprone-too-small-loop-variable]
for (unsigned class = 9; class < N_SIZE_CLASSES; class++) {
^
/home/strcat/projects/hardened_malloc/h_malloc.c:168:30: warning: loop variable has narrower type 'unsigned int' than iteration's upper bound 'unsigned long' [bugprone-too-small-loop-variable]
for (unsigned class = 1; class < N_SIZE_CLASSES; class++) {
^
/home/strcat/projects/hardened_malloc/h_malloc.c:236:28: warning: 4096 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
static_assert(PAGE_SIZE == 4096, "bitmap handling will need adjustment for other page sizes");
^
/home/strcat/projects/hardened_malloc/h_malloc.c:281:29: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
size_t bucket = index / 64;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:282:58: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
metadata->bitmap[bucket] |= 1UL << (index - bucket * 64);
^
/home/strcat/projects/hardened_malloc/h_malloc.c:289:29: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
size_t bucket = index / 64;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:290:60: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
metadata->bitmap[bucket] &= ~(1UL << (index - bucket * 64));
^
/home/strcat/projects/hardened_malloc/h_malloc.c:297:29: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
size_t bucket = index / 64;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:298:59: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
return (metadata->bitmap[bucket] >> (index - bucket * 64)) & 1UL;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:303:29: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
size_t bucket = index / 64;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:304:69: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
metadata->quarantine_bitmap[bucket] |= 1UL << (index - bucket * 64);
^
/home/strcat/projects/hardened_malloc/h_malloc.c:308:29: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
size_t bucket = index / 64;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:309:71: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
metadata->quarantine_bitmap[bucket] &= ~(1UL << (index - bucket * 64));
^
/home/strcat/projects/hardened_malloc/h_malloc.c:313:29: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
size_t bucket = index / 64;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:314:70: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
return (metadata->quarantine_bitmap[bucket] >> (index - bucket * 64)) & 1UL;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:319:20: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
return slots < 64 ? ~0UL << slots : 0;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:326:48: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
unsigned first_bitmap = random_index / 64;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:327:69: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
u64 random_split = ~(~0UL << (random_index - first_bitmap * 64));
^
/home/strcat/projects/hardened_malloc/h_malloc.c:333:30: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
if (i == slots / 64) {
^
/home/strcat/projects/hardened_malloc/h_malloc.c:334:48: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
masked |= get_mask(slots - i * 64);
^
/home/strcat/projects/hardened_malloc/h_malloc.c:338:47: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
return ffzl(masked) - 1 + i * 64;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:341:36: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
i = i == (slots - 1) / 64 ? 0 : i + 1;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:345:30: warning: loop variable has narrower type 'unsigned int' than iteration's upper bound 'unsigned long' [bugprone-too-small-loop-variable]
for (unsigned i = 0; i <= (slots - 1) / 64; i++) {
^
/home/strcat/projects/hardened_malloc/h_malloc.c:345:49: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
for (unsigned i = 0; i <= (slots - 1) / 64; i++) {
^
/home/strcat/projects/hardened_malloc/h_malloc.c:347:36: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
if (i == (slots - 1) / 64) {
^
/home/strcat/projects/hardened_malloc/h_malloc.c:348:48: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
masked |= get_mask(slots - i * 64);
^
/home/strcat/projects/hardened_malloc/h_malloc.c:352:47: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
return ffzl(masked) - 1 + i * 64;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:430:43: warning: 16 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
size_t size = info.size ? info.size : 16;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:613:16: warning: 16 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
size = 16;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:657:55: warning: 63 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
size_t quarantine_shift = __builtin_clzl(size) - (63 - MAX_SLAB_SIZE_CLASS_SHIFT);
^
/home/strcat/projects/hardened_malloc/h_malloc.c:960:34: warning: loop variable has narrower type 'unsigned int' than iteration's upper bound 'unsigned long' [bugprone-too-small-loop-variable]
for (unsigned class = 0; class < N_SIZE_CLASSES; class++) {
^
/home/strcat/projects/hardened_malloc/h_malloc.c:971:34: warning: loop variable has narrower type 'unsigned int' than iteration's upper bound 'unsigned long' [bugprone-too-small-loop-variable]
for (unsigned class = 0; class < N_SIZE_CLASSES; class++) {
^
/home/strcat/projects/hardened_malloc/h_malloc.c:993:34: warning: loop variable has narrower type 'unsigned int' than iteration's upper bound 'unsigned long' [bugprone-too-small-loop-variable]
for (unsigned class = 0; class < N_SIZE_CLASSES; class++) {
^
/home/strcat/projects/hardened_malloc/h_malloc.c:1080:34: warning: loop variable has narrower type 'unsigned int' than iteration's upper bound 'unsigned long' [bugprone-too-small-loop-variable]
for (unsigned class = 0; class < N_SIZE_CLASSES; class++) {
^
/home/strcat/projects/hardened_malloc/h_malloc.c:1093:24: warning: 16 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
size = 16;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:1128:21: warning: 16 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
h_free(h_malloc(16));
^
/home/strcat/projects/hardened_malloc/h_malloc.c:1143:32: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
size_t spacing_shift = 64 - __builtin_clzl(size - 1) - 3;
^
/home/strcat/projects/hardened_malloc/h_malloc.c:1618:34: warning: loop variable has narrower type 'unsigned int' than iteration's upper bound 'unsigned long' [bugprone-too-small-loop-variable]
for (unsigned class = 1; class < N_SIZE_CLASSES; class++) {
^
/home/strcat/projects/hardened_malloc/random.c:81:27: warning: 16 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
return multiresult >> 16;
^
/home/strcat/projects/hardened_malloc/random.c:108:27: warning: 64 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
return multiresult >> 64;
^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment