fixed some warnings
This commit is contained in:
parent
c6c70c6fcc
commit
c9864f3b68
@ -1,12 +1,24 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="ClangTidy" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="clangTidyCheckOptions">
|
||||
<list>
|
||||
<ClangTidyCheckOption />
|
||||
</list>
|
||||
</option>
|
||||
<option name="clangTidyChecks" value="-*,bugprone-argument-comment,bugprone-assert-side-effect,bugprone-bad-signal-to-kill-thread,bugprone-branch-clone,bugprone-copy-constructor-init,bugprone-dangling-handle,bugprone-dynamic-static-initializers,bugprone-fold-init-type,bugprone-forward-declaration-namespace,bugprone-forwarding-reference-overload,bugprone-inaccurate-erase,bugprone-incorrect-roundings,bugprone-integer-division,bugprone-lambda-function-name,bugprone-macro-repeated-side-effects,bugprone-misplaced-operator-in-strlen-in-alloc,bugprone-misplaced-pointer-arithmetic-in-alloc,bugprone-misplaced-widening-cast,bugprone-move-forwarding-reference,bugprone-multiple-statement-macro,bugprone-no-escape,bugprone-not-null-terminated-result,bugprone-parent-virtual-call,bugprone-posix-return,bugprone-sizeof-container,bugprone-sizeof-expression,bugprone-spuriously-wake-up-functions,bugprone-string-constructor,bugprone-string-integer-assignment,bugprone-string-literal-with-embedded-nul,bugprone-suspicious-enum-usage,bugprone-suspicious-include,bugprone-suspicious-memory-comparison,bugprone-suspicious-memset-usage,bugprone-suspicious-missing-comma,bugprone-suspicious-semicolon,bugprone-suspicious-string-compare,bugprone-swapped-arguments,bugprone-terminating-continue,bugprone-throw-keyword-missing,bugprone-too-small-loop-variable,bugprone-undefined-memory-manipulation,bugprone-undelegated-constructor,bugprone-unhandled-self-assignment,bugprone-unused-raii,bugprone-unused-return-value,bugprone-use-after-move,bugprone-virtual-near-miss,cert-dcl21-cpp,cert-dcl58-cpp,cert-err34-c,cert-err52-cpp,cert-err58-cpp,cert-err60-cpp,cert-flp30-c,cert-msc50-cpp,cert-msc51-cpp,cert-str34-c,cppcoreguidelines-interfaces-global-init,cppcoreguidelines-narrowing-conversions,cppcoreguidelines-pro-type-member-init,cppcoreguidelines-pro-type-static-cast-downcast,cppcoreguidelines-slicing,google-default-arguments,google-explicit-constructor,google-runtime-operator,hicpp-exception-baseclass,hicpp-multiway-paths-covered,misc-misplaced-const,misc-new-delete-overloads,misc-no-recursion,misc-non-copyable-objects,misc-throw-by-value-catch-by-reference,misc-unconventional-assign-operator,misc-uniqueptr-reset-release,modernize-avoid-bind,modernize-concat-nested-namespaces,modernize-deprecated-headers,modernize-deprecated-ios-base-aliases,modernize-loop-convert,modernize-make-shared,modernize-make-unique,modernize-pass-by-value,modernize-raw-string-literal,modernize-redundant-void-arg,modernize-replace-auto-ptr,modernize-replace-disallow-copy-and-assign-macro,modernize-replace-random-shuffle,modernize-return-braced-init-list,modernize-shrink-to-fit,modernize-unary-static-assert,modernize-use-auto,modernize-use-bool-literals,modernize-use-emplace,modernize-use-equals-default,modernize-use-equals-delete,modernize-use-nodiscard,modernize-use-noexcept,modernize-use-nullptr,modernize-use-override,modernize-use-transparent-functors,modernize-use-uncaught-exceptions,mpi-buffer-deref,mpi-type-mismatch,openmp-use-default-none,performance-faster-string-find,performance-for-range-copy,performance-implicit-conversion-in-loop,performance-inefficient-algorithm,performance-inefficient-string-concatenation,performance-inefficient-vector-operation,performance-move-const-arg,performance-move-constructor-init,performance-no-automatic-move,performance-noexcept-move-constructor,performance-trivially-destructible,performance-type-promotion-in-math-fn,performance-unnecessary-copy-initialization,performance-unnecessary-value-param,portability-simd-intrinsics,readability-avoid-const-params-in-decls,readability-const-return-type,readability-container-size-empty,readability-convert-member-functions-to-static,readability-delete-null-pointer,readability-deleted-default,readability-inconsistent-declaration-parameter-name,readability-make-member-function-const,readability-misleading-indentation,readability-misplaced-array-index,readability-non-const-parameter,readability-redundant-control-flow,readability-redundant-declaration,readability-redundant-function-ptr-dereference,readability-redundant-smartptr-get,readability-redundant-string-cstr,readability-redundant-string-init,readability-simplify-subscript-expr,readability-static-accessed-through-instance,readability-static-definition-in-anonymous-namespace,readability-string-compare,readability-uniqueptr-delete-release,readability-use-anyofallof" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="EmptyDeclOrStmt" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="GrazieInspection" enabled="false" level="TYPO" enabled_by_default="false" />
|
||||
<inspection_tool class="LanguageDetectionInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="Misra" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="OCUnusedGlobalDeclaration" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
|
||||
<option name="processCode" value="true" />
|
||||
<option name="processLiterals" value="true" />
|
||||
<option name="processComments" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="UnconstrainedVariableType" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
||||
@ -7,7 +7,6 @@
|
||||
</sourceRoots>
|
||||
<excludeRoots>
|
||||
<file path="$PROJECT_DIR$/.vscode" />
|
||||
<file path="$PROJECT_DIR$/bin" />
|
||||
</excludeRoots>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
|
||||
14
Makefile
14
Makefile
@ -3,10 +3,10 @@ TESTS=$(wildcard tests/*c) $(wildcard tests/**/*.c)
|
||||
|
||||
OUTDIR=bin
|
||||
CMP=gcc
|
||||
OPT_ARGS=-O2 -std=c17
|
||||
OPT_ARGS=-O2 -flto -std=c17
|
||||
WARN_ARGS=-Wall -Wno-discarded-qualifiers
|
||||
|
||||
all: clear_c clear_bin build_test build_lib
|
||||
all: clear_c clear_bin build_test_dbg
|
||||
|
||||
clear_c:
|
||||
clear
|
||||
@ -43,6 +43,16 @@ build_lib:
|
||||
@echo -e '\n\e[96m-------------[build_lib]--------------\e[0m'
|
||||
$(CMP) $(LIB_ARGS) -o $(OUTDIR)/$(LIB_FILE)
|
||||
|
||||
DLL_ARGS=$(OPT_ARGS) $(WARN_ARGS)\
|
||||
-shared -fpic -static-libgcc -static-libstdc++\
|
||||
$(SRC) tests/test_marshalling.c
|
||||
DLL_FILE=kerep.dll
|
||||
|
||||
build_dll:
|
||||
gcc --version
|
||||
@echo -e '\n\e[96m-------------[build_dll]--------------\e[0m'
|
||||
$(CMP) $(DLL_ARGS) -o $(OUTDIR)/$(DLL_FILE)
|
||||
|
||||
######################################
|
||||
###### Run tasks #######
|
||||
######################################
|
||||
|
||||
@ -44,7 +44,7 @@ Maybe ERROR_WRONGCHAR(const char c, char* _text, char* text_first, const char* s
|
||||
if(!_c) break;
|
||||
}
|
||||
char errmsg[1024];
|
||||
IFWIN(
|
||||
IFMSC(
|
||||
sprintf_s(errmsg,1024, "unexpected <%c> at:\n"
|
||||
" \"%s\"\n"
|
||||
"\\___[%s:%d] %s()",
|
||||
@ -85,7 +85,6 @@ Maybe __ReadName(DeserializeSharedData* shared){
|
||||
case '[': case ']':
|
||||
case '{':
|
||||
safethrow_wrongchar(c,;);
|
||||
break;
|
||||
case '#': ;
|
||||
char _c=c;
|
||||
char* _text=text;
|
||||
@ -180,7 +179,6 @@ Maybe __ParseValue(DeserializeSharedData* shared, string str){
|
||||
else if(string_compare(str,falseStr))
|
||||
return SUCCESS(UniFalse);
|
||||
else safethrow_wrongchar(*str.ptr,;);
|
||||
break;
|
||||
// Float64
|
||||
case 'f': {
|
||||
char* _c=string_extract(str);
|
||||
@ -192,9 +190,9 @@ Maybe __ParseValue(DeserializeSharedData* shared, string str){
|
||||
case 'u': {
|
||||
uint64 lu=0;
|
||||
char* _c=string_extract(str);
|
||||
if(sscanf(_c,"%lu",&lu)!=1){
|
||||
if(sscanf(_c, IFWIN("%llu", "%lu"), &lu)!=1){
|
||||
char err[64];
|
||||
IFWIN(
|
||||
IFMSC(
|
||||
sprintf_s(err,64,"can't parse to int: <%s>",_c),
|
||||
sprintf(err,"can't parse to int: <%s>",_c)
|
||||
);
|
||||
@ -208,9 +206,9 @@ Maybe __ParseValue(DeserializeSharedData* shared, string str){
|
||||
case '5': case '6': case '7': case '8': case '9': {
|
||||
int64 li=0;
|
||||
char* _c=string_extract(str);
|
||||
if(sscanf(_c,"%li",&li)!=1){
|
||||
if(sscanf(_c, IFWIN("%lli", "%li"), &li)!=1){
|
||||
char err[64];
|
||||
IFWIN(
|
||||
IFMSC(
|
||||
sprintf_s(err,64,"can't parse to int: <%s>",_c),
|
||||
sprintf(err,"can't parse to int: <%s>",_c)
|
||||
);
|
||||
@ -245,7 +243,6 @@ Maybe __ReadValue(DeserializeSharedData* shared, bool* readingList){
|
||||
case '}': case '$':
|
||||
case '\'':
|
||||
safethrow_wrongchar(c,Unitype_free(value));
|
||||
break;
|
||||
case '#':;
|
||||
char _c=c;
|
||||
char* _text=text;
|
||||
|
||||
@ -49,7 +49,6 @@ Maybe __AppendValue(SerializeSharedData* shared, Unitype u){
|
||||
break;
|
||||
case Null:
|
||||
safethrow("Null isn't supported in DtsodV24",;);
|
||||
break;
|
||||
case AutoarrUnitypePtr:
|
||||
if(Autoarr_length(((Autoarr_Unitype*)(u.VoidPtr)))){
|
||||
addc('\n');
|
||||
@ -79,7 +78,7 @@ Maybe __AppendValue(SerializeSharedData* shared, Unitype u){
|
||||
goto hashtableNotBlank;
|
||||
if(__.key); // weird way to disable warning
|
||||
}));
|
||||
|
||||
|
||||
|
||||
// blank hashtable
|
||||
addc('{');
|
||||
@ -96,7 +95,7 @@ Maybe __AppendValue(SerializeSharedData* shared, Unitype u){
|
||||
AppendTabs();
|
||||
addc('}');
|
||||
break;
|
||||
default: dbg((u.type)); safethrow(ERR_WRONGTYPE,;);
|
||||
default: dbg((u.type)); safethrow(ERR_WRONGTYPE,;);
|
||||
}
|
||||
|
||||
return MaybeNull;
|
||||
@ -104,11 +103,11 @@ Maybe __AppendValue(SerializeSharedData* shared, Unitype u){
|
||||
|
||||
Maybe __serialize(StringBuilder* _b, uint8 _tabs, Hashtable* dtsod){
|
||||
SerializeSharedData _shared={
|
||||
.sh_builder=_b,
|
||||
.sh_builder=_b,
|
||||
.sh_tabs=_tabs
|
||||
};
|
||||
SerializeSharedData* shared=&_shared;
|
||||
|
||||
|
||||
Hashtable_foreach(dtsod, p, ({
|
||||
AppendTabs();
|
||||
StringBuilder_append_cptr(b,p.key);
|
||||
|
||||
@ -37,7 +37,7 @@ void Hashtable_expand(Hashtable* ht){
|
||||
for(uint16 i=0;i<HT_HEIGHTS[ht->hein-1];i++){
|
||||
Autoarr(KVPair)* ar=ht->rows[i];
|
||||
uint32 arlen=Autoarr_length(ar);
|
||||
for(uint16 k=0;k<arlen;k++){
|
||||
for(uint32 k=0;k<arlen;k++){
|
||||
KVPair p=Autoarr_get(ar,k);
|
||||
uint16 newrown=ihash(p.key)%HT_HEIGHTS[ht->hein];
|
||||
Autoarr(KVPair)* newar=newrows[newrown];
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
define_Autoarr(string)
|
||||
|
||||
#define MAXLENGTH 32768
|
||||
#define BL_C 32
|
||||
#define BL_L 1024
|
||||
|
||||
@ -136,7 +135,7 @@ void StringBuilder_append_uint64(StringBuilder* b, uint64 a){
|
||||
void StringBuilder_append_float64(StringBuilder* b, double a){
|
||||
try_complete_buf(b);
|
||||
char buf[32];
|
||||
IFWIN(
|
||||
IFMSC(
|
||||
sprintf_s(buf,32,"%lf",a),
|
||||
sprintf(buf,"%lf",a)
|
||||
);
|
||||
|
||||
@ -20,7 +20,7 @@ char* errname(err_t err){
|
||||
char* __genErrMsg(const char* errmsg, const char* srcfile, int line, const char* funcname){
|
||||
size_t bufsize=ERRMSG_MAXLENGTH;
|
||||
char* rezult=malloc(bufsize);
|
||||
IFWIN(
|
||||
IFMSC(
|
||||
sprintf_s(rezult,bufsize,"[%s:%d] %s() throwed error: %s",srcfile,line,funcname,errmsg),
|
||||
sprintf(rezult,"[%s:%d] %s() throwed error: %s",srcfile,line,funcname,errmsg)
|
||||
);
|
||||
@ -30,7 +30,7 @@ char* __genErrMsg(const char* errmsg, const char* srcfile, int line, const char*
|
||||
char* __extendErrMsg(const char* errmsg, const char* srcfile, int line, const char* funcname){
|
||||
size_t bufsize=cptr_length(errmsg)+ERRMSG_MAXLENGTH;
|
||||
char* rezult=malloc(bufsize);
|
||||
IFWIN(
|
||||
IFMSC(
|
||||
sprintf_s(rezult,bufsize,"%s\n \\___[%s:%d] %s()",errmsg,srcfile,line,funcname),
|
||||
sprintf(rezult,"%s\n \\___[%s:%d] %s()",errmsg,srcfile,line,funcname)
|
||||
);
|
||||
|
||||
@ -40,8 +40,13 @@ extern "C" {
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define IFWIN(YES, NO) YES
|
||||
#define IFMSC(YES, NO) NO
|
||||
#elif defined(_WIN64) || defined(_WIN32)
|
||||
#define IFWIN(YES, NO) YES
|
||||
#define IFMSC(YES, NO) NO
|
||||
#elif defined(__GNUC__)
|
||||
#define IFWIN(YES, NO) NO
|
||||
#define IFMSC(YES, NO) NO
|
||||
#else
|
||||
#pragma GCC error "unknown compiler"
|
||||
#endif
|
||||
|
||||
@ -116,7 +116,7 @@ void Unitype_free(Unitype u){
|
||||
#define BUFSIZE 64
|
||||
char* sprintuni(Unitype v){
|
||||
char* buf=malloc(BUFSIZE);
|
||||
IFWIN(
|
||||
IFMSC(
|
||||
switch (v.type) {
|
||||
case Null: sprintf_s(buf, BUFSIZE, "{Null}");break;
|
||||
case Float64: sprintf_s(buf, BUFSIZE, "{%s : %lf}", my_type_name(v.type),v.Float64);break;
|
||||
@ -131,17 +131,17 @@ char* sprintuni(Unitype v){
|
||||
default: sprintf_s(buf, BUFSIZE, "{%s : %p}", my_type_name(v.type),v.VoidPtr);break;
|
||||
},
|
||||
switch (v.type) {
|
||||
case Null: sprintf(buf, "{Null}");break;
|
||||
case Float64: sprintf(buf, "{%s : %lf}", my_type_name(v.type),v.Float64);break;
|
||||
case Null: sprintf(buf, "{Null}"); break;
|
||||
case Float64: sprintf(buf, "{%s : %lf}", my_type_name(v.type),v.Float64); break;
|
||||
case Bool:
|
||||
case UInt64: sprintf(buf, "{%s : %lu}", my_type_name(v.type),v.UInt64);break;
|
||||
case Int64: sprintf(buf, "{%s : %ld}", my_type_name(v.type),v.Int64);break;
|
||||
case UInt64: sprintf(buf, "{%s : " IFWIN("%llu", "%lu") "}", my_type_name(v.type),v.UInt64); break;
|
||||
case Int64: sprintf(buf, "{%s : " IFWIN("%lld", "%ld") "}", my_type_name(v.type),v.Int64); break;
|
||||
case CharPtr: ;
|
||||
size_t newBUFSIZE=cptr_length(v.VoidPtr) + BUFSIZE/2;
|
||||
buf=realloc(buf, newBUFSIZE);
|
||||
sprintf(buf, "{%s : \"%s\"}", my_type_name(v.type),(char*)v.VoidPtr);
|
||||
break;
|
||||
default: sprintf(buf, "{%s : %p}", my_type_name(v.type),v.VoidPtr);break;
|
||||
default: sprintf(buf, "{%s : %p}", my_type_name(v.type),v.VoidPtr);break;
|
||||
}
|
||||
);
|
||||
return buf;
|
||||
|
||||
@ -20,17 +20,17 @@ static void printautoarr(Autoarr(uint16)* ar){
|
||||
}
|
||||
|
||||
static void fillar(Autoarr(uint16)* ar){
|
||||
for (uint16 i=0;i<Autoarr_max_length(ar);i++)
|
||||
for (uint32 i=0;i<Autoarr_max_length(ar);i++)
|
||||
Autoarr_add(ar,i);
|
||||
}
|
||||
static void resetar(Autoarr(uint16)* ar){
|
||||
for (uint16 i=0;i<Autoarr_max_length(ar);i++)
|
||||
for (uint32 i=0;i<Autoarr_max_length(ar);i++)
|
||||
Autoarr_set(ar,i,Autoarr_max_length(ar)-i-1);
|
||||
}
|
||||
|
||||
static void printallval(Autoarr(uint16)* ar){
|
||||
printf("\e[90m");
|
||||
for (uint16 i=0;i<Autoarr_length(ar);i++)
|
||||
for (uint32 i=0;i<Autoarr_length(ar);i++)
|
||||
printf("%u ",Autoarr_get(ar,i));
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ void printrowgraph(Hashtable* ht){
|
||||
|
||||
char* genkey(uint32 i){
|
||||
char* key=malloc(12);
|
||||
IFWIN(
|
||||
IFMSC(
|
||||
sprintf_s(key,12,"key_%u",i),
|
||||
sprintf(key,"key_%u",i)
|
||||
);
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
|
||||
#include "../src/base/base.h"
|
||||
|
||||
void printuni(Unitype v);
|
||||
|
||||
void test_searchtree();
|
||||
void test_autoarr();
|
||||
void test_hashtable();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user