diff --git a/.github/workflows/c-tests.yml b/.github/workflows/c-tests.yml index 7353e59ba..2e3c373d3 100644 --- a/.github/workflows/c-tests.yml +++ b/.github/workflows/c-tests.yml @@ -53,7 +53,7 @@ jobs: # Doesn't work on Windows. - name: Clang Sanitizers if: matrix.os != 'windows-latest' - run: make sanitize + run: CC=clang make sanitize # Run static analyzer. # Doesn't work on Windows. diff --git a/src/Makefile b/src/Makefile index 96745cb58..946c8fd55 100644 --- a/src/Makefile +++ b/src/Makefile @@ -20,7 +20,7 @@ ifeq ($(PLATFORM),Darwin) endif # The base compiler flags. More can be added on command line. -CFLAGS += -I. -I../inc -O2 -Werror -Wno-gnu-folding-constant +CFLAGS += -I. -I../inc -O2 # Enable a bunch of optional warnings. CFLAGS += \ -pedantic \ @@ -43,6 +43,7 @@ CFLAGS += \ -Winit-self \ -Winline \ -Winvalid-pch \ + -Wmissing-braces \ -Wmissing-declarations \ -Wmissing-field-initializers \ -Wmissing-format-attribute \ @@ -75,13 +76,15 @@ CFLAGS += \ # Cross-platform compilation settings. ifeq ($(PLATFORM),Windows) - CC = gcc + CC ?= gcc CFLAGS += -D_CRT_SECURE_NO_WARNINGS - CFLAGS += -Wno-missing-braces -Wno-format + CFLAGS += -Wno-format else - CC = clang + CC ?= clang CFLAGS += -fPIC - CFLAGS += -Wmissing-braces -Wformat=2 +ifeq ($(CC),clang) + CFLAGS += -Werror -Wno-gnu-folding-constant -Wformat=2 +endif endif # Settings for blst. @@ -219,7 +222,10 @@ sanitize_%: blst $(SOURCE_FILES) $(HEADER_FILES) ./$@; rm $@ .PHONY: sanitize -ifeq ($(PLATFORM),Darwin) +ifneq ($(CC),clang) +sanitize: + $(error sanitize requires CC=clang) +else ifeq ($(PLATFORM),Darwin) sanitize: \ sanitize_address \ sanitize_undefined diff --git a/src/common/ec.h b/src/common/ec.h index c2cc0f0cb..0db819814 100644 --- a/src/common/ec.h +++ b/src/common/ec.h @@ -32,7 +32,7 @@ typedef blst_p2 g2_t; /**< Internal G2 group element type. */ /** Deserialized form of the G1 identity/infinity point. */ static const g1_t G1_IDENTITY = { - {0L, 0L, 0L, 0L, 0L, 0L}, {0L, 0L, 0L, 0L, 0L, 0L}, {0L, 0L, 0L, 0L, 0L, 0L} + {{0L, 0L, 0L, 0L, 0L, 0L}}, {{0L, 0L, 0L, 0L, 0L, 0L}}, {{0L, 0L, 0L, 0L, 0L, 0L}} }; //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/common/fr.h b/src/common/fr.h index 0e97242bb..519051e5e 100644 --- a/src/common/fr.h +++ b/src/common/fr.h @@ -41,16 +41,16 @@ typedef blst_fr fr_t; /**< Internal Fr field element type. */ //////////////////////////////////////////////////////////////////////////////////////////////////// /** The zero field element. */ -static const fr_t FR_ZERO = {0L, 0L, 0L, 0L}; +static const fr_t FR_ZERO = {{0L, 0L, 0L, 0L}}; /** This is 1 in blst's `blst_fr` limb representation. Crazy but true. */ static const fr_t FR_ONE = { - 0x00000001fffffffeL, 0x5884b7fa00034802L, 0x998c4fefecbc4ff5L, 0x1824b159acc5056fL + {0x00000001fffffffeL, 0x5884b7fa00034802L, 0x998c4fefecbc4ff5L, 0x1824b159acc5056fL} }; /** This used to represent a missing element. It's an invalid value. */ static const fr_t FR_NULL = { - 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL + {0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL} }; //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/eip7594/fft.c b/src/eip7594/fft.c index 91ddd83d8..a629652f1 100644 --- a/src/eip7594/fft.c +++ b/src/eip7594/fft.c @@ -35,7 +35,7 @@ * printf("%#018llxL,\n", a.l[i]); */ static const fr_t RECOVERY_SHIFT_FACTOR = { - 0x0000000efffffff1L, 0x17e363d300189c0fL, 0xff9c57876f8457b0L, 0x351332208fc5a8c4L + {0x0000000efffffff1L, 0x17e363d300189c0fL, 0xff9c57876f8457b0L, 0x351332208fc5a8c4L} }; /** @@ -48,7 +48,7 @@ static const fr_t RECOVERY_SHIFT_FACTOR = { * printf("%#018llxL,\n", a.l[i]); */ static const fr_t INV_RECOVERY_SHIFT_FACTOR = { - 0xdb6db6dadb6db6dcL, 0xe6b5824adb6cc6daL, 0xf8b356e005810db9L, 0x66d0f1e660ec4796L + {0xdb6db6dadb6db6dcL, 0xe6b5824adb6cc6daL, 0xf8b356e005810db9L, 0x66d0f1e660ec4796L} }; //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/setup/setup.c b/src/setup/setup.c index 5d8d4972d..1686afaef 100644 --- a/src/setup/setup.c +++ b/src/setup/setup.c @@ -79,7 +79,7 @@ * factor changes, this constant is no longer correct. */ static const fr_t ROOT_OF_UNITY = { - 0xa33d279ff0ccffc9L, 0x41fac79f59e91972L, 0x065d227fead1139bL, 0x71db41abda03e055L + {0xa33d279ff0ccffc9L, 0x41fac79f59e91972L, 0x065d227fead1139bL, 0x71db41abda03e055L} }; ////////////////////////////////////////////////////////////////////////////////////////////////////