diff options
| -rw-r--r-- | Makefile | 17 | ||||
| -rw-r--r-- | list.h | 5 |
2 files changed, 18 insertions, 4 deletions
@@ -1,10 +1,23 @@ mode ?= debug +# https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html +common_cflags = -Wall -Wno-sign-conversion -Wno-conversion -Wformat -Wformat=2 \ + -Werror=format-security \ + -D_GLIBCXX_ASSERTIONS \ + -fstrict-flex-arrays=3 \ + -fstack-clash-protection -fstack-protector-strong \ + -Wtrampolines -fzero-init-padding-bits=all \ + -Wbidi-chars=any \ + -Werror=implicit -Werror=incompatible-pointer-types -Werror=int-conversion \ + -fexceptions + cc = gcc ifeq ($(mode), debug) - cflags = -g + cflags = $(common_cflags) -g -Werror else - cflags = -O2 + cflags = $(common_cflags) -O2 \ + -fno-delete-null-pointer-checks -fno-strict-overflow -fno-strict-aliasing -ftrivial-auto-var-init=zero \ + -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 endif src = $(shell ls *.c) @@ -21,7 +21,7 @@ } T##List; \ void T##List_init(T##List *self); \ void T##List_free(T##List *self); \ - void T##List_move(T##List *self); \ + T##List T##List_move(T##List *self); \ T##ListIter T##List_insert_before(T##List *self, T##ListIter iter, T val); \ T##ListIter T##List_insert_after(T##List *self, T##ListIter iter, T val); \ void T##List_remove(T##List *self, T##ListIter iter); \ @@ -56,7 +56,7 @@ LIST_DEF(Int); cur = next; \ } \ } \ - void T##List_move(T##List *self) { \ + T##List T##List_move(T##List *self) { \ T##List dup; \ dup.vhead = self->vhead; \ dup.vtail = self->vtail; \ @@ -64,6 +64,7 @@ LIST_DEF(Int); self->vhead = NULL; \ self->vtail = NULL; \ self->len = 0; \ + return dup; \ } \ T##ListIter T##List_insert_before(T##List *self, T##ListIter iter, T val) { \ if (iter->prev == NULL) return NULL; \ |
