From e9b5fe5f0a9a93de89a3d0b8238f36ac964ff702 Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Fri, 22 Jun 2018 21:01:16 +0200 Subject: [PATCH] Add gcc flags to improve reliability --- Makefile | 5 +++-- standart.c | 6 +++--- udev.c | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index c46e797..e53c544 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ CXX=gcc -CXXFLAGS=-g -Wall -Werror -fstack-protector-all -pedantic -Wno-unused +CXXFLAGS=-g -Wall -Wextra -Werror -fstack-protector-all -pedantic -Wno-unused +SANITY_FLAGS=-Wfloat-equal -Wshadow -Wpointer-arith -Wstrict-overflow=5 -Wformat=2 SOURCE=main.c standart.c extended.c cpuid.c udev.c printer.c args.c global.c HEADERS=standart.h extended.h cpuid.h udev.h printer.h ascii.h args.h global.h @@ -8,7 +9,7 @@ HEADERS=standart.h extended.h cpuid.h udev.h printer.h ascii.h args.h global.h OUTPUT=cpufetch $(OUTPUT): Makefile $(SOURCE) $(HEADERS) - $(CXX) $(CXXFLAGS) $(SOURCE) -o $(OUTPUT) + $(CXX) $(CXXFLAGS) $(SANITY_FLAGS) $(SOURCE) -o $(OUTPUT) run: ./$(OUTPUT) diff --git a/standart.c b/standart.c index 2a80da4..be9a13b 100644 --- a/standart.c +++ b/standart.c @@ -49,9 +49,9 @@ struct cpuInfo { /*** Threads per core(Intel HyperThreading) ***/ int HT; /*** Max CPUIDs levels ***/ - int maxLevels; + unsigned maxLevels; /*** Max CPUIDs extended levels ***/ - int maxExtendedLevels; + unsigned maxExtendedLevels; }; void initializeCpuInfo(struct cpuInfo* cpu) { @@ -224,7 +224,7 @@ char* getPeakPerformance(struct cpuInfo* cpu, long freq) { ***/ //7 for GFLOP/s and 6 for digits,eg 412.14 - int size = 7+6+1+1; + unsigned int size = 7+6+1+1; assert(strlen(STRING_UNKNOWN)+1 <= size); char* string = malloc(sizeof(char)*size); diff --git a/udev.c b/udev.c index c114a02..ca69027 100644 --- a/udev.c +++ b/udev.c @@ -161,7 +161,7 @@ char* getString_L3(struct cache* cach) { char* getString_MaxFrequency(struct frequency* freq) { //Max 3 digits and 3 for '(M/G)Hz' plus 1 for '\0' - int size = (4+3+1); + unsigned int size = (4+3+1); assert(strlen(STRING_UNKNOWN)+1 <= size); char* string = malloc(sizeof(char)*size); if(freq->max == UNKNOWN)