From 88643796b7cce57e54b9f6d4cd75876f56e2fe6c Mon Sep 17 00:00:00 2001 From: Rasmus Edgar Date: Wed, 7 Aug 2024 20:48:11 +0200 Subject: [PATCH] Clean up. Fix memleak. Better data structure. --- Makefile | 4 +- README.md | 23 +++++++-- include/commodity.h | 14 +++--- include/dintwm.h | 2 + include/dintwm_shared.h | 8 ---- include/wbar_config.h | 12 ++--- readme.txt | 22 +++++++-- src/commodity.c | 76 ++++++++++++------------------ src/dintwm.c | 101 +++++++++++++++++++--------------------- 9 files changed, 133 insertions(+), 129 deletions(-) diff --git a/Makefile b/Makefile index 73615a4..e3b1fa8 100644 --- a/Makefile +++ b/Makefile @@ -6,13 +6,13 @@ endef ifdef fortify FTFYSRC = fortify.c FTFYHDRS = fortify.h ufortify.h -FTFYFLAG =-DFORTIFY +FTFYFLAG ="-DFORTIFY " FTFYLINTEXCL = --exclude=fortify.* endif SOURCES = src/dintwm.c src/commodity.c $(FTFYSRC) OBJECTS = $(SOURCES:.c=.o) -CFLAGSSTRICT =-pedantic -std=c11 -ggdb3 $(FTFYFLAG) -O2 -Wall -Wextra -Wformat=2 -Wmissing-include-dirs -Winit-self -Wswitch-default -Wswitch-enum -Wunused-parameter -Wfloat-equal -Wundef -Wshadow -Wlarger-than-1000 -Wunsafe-loop-optimizations -Wbad-function-cast -Wcast-align -Wconversion -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpacked -Wpadded -Wredundant-decls -Wnested-externs -Wunreachable-code -Winline -Winvalid-pch -Wvolatile-register-var -Wstrict-aliasing=2 -Wstrict-overflow=2 -Wtraditional-conversion -Wwrite-strings -noixemul -save-temps=obj +CFLAGSSTRICT =-pedantic -std=c11 -ggdb3 $(FTFYFLAG)-O2 -Wall -Wextra -Wformat=2 -Wmissing-include-dirs -Winit-self -Wswitch-default -Wswitch-enum -Wunused-parameter -Wfloat-equal -Wundef -Wshadow -Wlarger-than-1000 -Wunsafe-loop-optimizations -Wbad-function-cast -Wcast-align -Wconversion -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpacked -Wpadded -Wredundant-decls -Wnested-externs -Wunreachable-code -Winline -Winvalid-pch -Wvolatile-register-var -Wstrict-aliasing=2 -Wstrict-overflow=2 -Wtraditional-conversion -Wwrite-strings -noixemul -save-temps=obj CC = m68k-amigaos-gcc CFLAGS =-std=c11 -Ofast -Wall -Wextra -s -fomit-frame-pointer -noixemul MAINHEADER = include/dintwm.h include/dintwm_shared.h diff --git a/README.md b/README.md index 6dd399c..c483f3e 100644 --- a/README.md +++ b/README.md @@ -279,11 +279,28 @@ Ketopt.h from https://github.com/attractivechaos/klib is licensed under the MIT/ ## SAST Tools -[PVS-Studio](https://pvs-studio.com/en/pvs-studio/?utm_source=github&utm_medium=organic&utm_campaign=open_source) - static analyzer for C, C++, C#, and Java code. - -Other analyzers used are: +Static analyzers used are: [splint](https://splint.org/) [flawfinder](https://github.com/david-a-wheeler/flawfinder) [cppcheck](https://cppcheck.sourceforge.io/) Check out the Makefile on how this project uses them. + +## Memleak checker + +This part I find difficult to check for when compiling for a m68k target (no valgrind). + +Settled on [fortify](http://aminet.net/package/dev/c/fortify22) which helped me identify a memory leak. + +It can be enabled by building the source with: +``` +wget http://aminet.net/dev/c/fortify22.lha +lha x fortify22.lha -w=/tmp +cp /tmp/FORTIFY.CXX fortify.c +cp /tmp/UFORTIFY.H ufortify.h +cp /tmp/FORTIFY.H fortify.h +make strict=true fortify=true all +rm {uf,f}ortify* +``` + +When running the dintwm binary on AmigaOS, some memory allocation statistics will be displayed hopefully showing no memory leaks. diff --git a/include/commodity.h b/include/commodity.h index 40d6cee..db6bf99 100644 --- a/include/commodity.h +++ b/include/commodity.h @@ -138,28 +138,28 @@ #define KEY_INCALLGAPS_TXT "rawkey " MOD1 " " MOD2 " numericpad +" #define KEY_DECALLGAPS_TXT "rawkey " MOD1 " " MOD2 " numericpad --" #define KEY_TILE_OFF_TXT "rawkey " MOD1 " " MOD2 " o" -#define KEY_CMD_0_TXT "rawkey " MOD1 " " MOD2 " j" +#define KEY_CMD_0_TXT "rawkey " MOD1 " " MOD2 " 0" #define KEY_CMD_1_TXT "rawkey " MOD1 " " MOD2 " 1" #define KEY_CMD_2_TXT "rawkey " MOD1 " " MOD2 " 2" #define KEY_CMD_3_TXT "rawkey " MOD1 " " MOD2 " 3" #define KEY_CMD_4_TXT "rawkey " MOD1 " " MOD2 " 4" -#define KEY_CMD_5_TXT "rawkey " MOD1 " " MOD2 " k" +#define KEY_CMD_5_TXT "rawkey " MOD1 " " MOD2 " 5" #define KEY_CMD_6_TXT "rawkey " MOD1 " " MOD2 " 6" #define KEY_CMD_7_TXT "rawkey " MOD1 " " MOD2 " 7" #define KEY_CMD_8_TXT "rawkey " MOD1 " " MOD2 " 8" #define KEY_CMD_9_TXT "rawkey " MOD1 " " MOD2 " 9" -#define KEY_WS_0_TXT "rawkey " MOD1 " " MOD2 " 0" +#define KEY_WS_0_TXT "rawkey " MOD1 " " MOD2 " numericpad 0" #define KEY_WS_1_TXT "rawkey " MOD1 " " MOD2 " numericpad 1" #define KEY_WS_2_TXT "rawkey " MOD1 " " MOD2 " numericpad 2" #define KEY_WS_3_TXT "rawkey " MOD1 " " MOD2 " numericpad 3" #define KEY_WS_4_TXT "rawkey " MOD1 " " MOD2 " numericpad 4" -#define KEY_WS_5_TXT "rawkey " MOD1 " " MOD2 " 5" -#define KEY_CWS_0_TXT "rawkey " MOD1 " " MOD3 " 0" +#define KEY_WS_5_TXT "rawkey " MOD1 " " MOD2 " numericpad 5" +#define KEY_CWS_0_TXT "rawkey " MOD1 " " MOD3 " numericpad 0" #define KEY_CWS_1_TXT "rawkey " MOD1 " " MOD3 " numericpad 1" #define KEY_CWS_2_TXT "rawkey " MOD1 " " MOD3 " numericpad 2" #define KEY_CWS_3_TXT "rawkey " MOD1 " " MOD3 " numericpad 3" #define KEY_CWS_4_TXT "rawkey " MOD1 " " MOD3 " numericpad 4" -#define KEY_CWS_5_TXT "rawkey " MOD1 " " MOD3 " 5" +#define KEY_CWS_5_TXT "rawkey " MOD1 " " MOD3 " numericpad 5" #define KEY_CXM_EXIT_TXT "rawkey " MOD1 " " MOD2 " q" #define KEY_TAB_NEXT_TXT "rawkey " MOD1 " " MOD2 " tab" @@ -169,7 +169,7 @@ static short attachtooltypes(CxObj *broker, struct MsgPort *port, struct DiskObject *diskobj); static short alloc_opts(const char *tt_optvalue, Ostore *s, size_t i, int subtract); static void free_opts(void); -static short alloc_bar_item(Bar_Text *b, enum bar_texts x, const char *c); +static short assign_bar_item(Bar_Text *b, enum bar_texts x, const char *c); static void cleanup(void); static struct Library *iconbase; diff --git a/include/dintwm.h b/include/dintwm.h index 73fda2e..6a66a34 100644 --- a/include/dintwm.h +++ b/include/dintwm.h @@ -2,7 +2,9 @@ #include #include "../include/ketopt.h" #include "../include/wbar_config.h" +#ifdef FORTIFY #include "../fortify.h" +#endif //VERCUT #define DINTWM_VERSION "VERGIT" diff --git a/include/dintwm_shared.h b/include/dintwm_shared.h index 9f05d57..d80169f 100644 --- a/include/dintwm_shared.h +++ b/include/dintwm_shared.h @@ -169,8 +169,6 @@ #define DEF_BAR_BP_SEP_TWO_COL 3U // Default bar title backpen color #define DEF_BAR_BG_COL 3U // Default bar bg color -#define WTSTRING_INIT_SIZE 256U // Allow 128 windows before realloc of wtstring - #define MOD1 "control" #define MOD2 "lcommand" #define MOD3 "shift" @@ -209,7 +207,6 @@ short spiral(const Arg *arg); short dwindle(const Arg *arg); short switcher(const Arg *arg); short changegaps(const Arg *arg); -//int countwindows(int lock, int assign_winfo); int countwindows(int lock); void getactive(void); int cstring_cmp(const void *a, const void *b); @@ -236,7 +233,6 @@ extern long int *current_layout; extern int exclude_wtype; extern int include_wtype; extern long unsigned int auto_interval; -//extern unsigned int current_ws; extern short backdropped; extern short tile_off; extern struct Window *wbw; @@ -342,13 +338,9 @@ void time_delay(struct timerequest *tr, const struct timeval *tv); typedef struct { short wbwin; - //unsigned int workspace; enum ws_num workspace; short skip; struct Window *wptr; } Winfo; Winfo *winfo; - -extern int malloc_count; -extern int free_count; diff --git a/include/wbar_config.h b/include/wbar_config.h index 0b9050a..5cb6837 100644 --- a/include/wbar_config.h +++ b/include/wbar_config.h @@ -15,9 +15,9 @@ static struct IntuiText wbartext = .TopEdge = 4, .LeftEdge = 0, .ITextFont = NULL, - .DrawMode = JAM2, //-V2568 - .FrontPen = 0, //-V2568 - .BackPen = 0, //-V2568 + .DrawMode = JAM2, + .FrontPen = 0, + .BackPen = 0, .IText = NULL, .NextText = NULL }; @@ -37,9 +37,9 @@ static struct Border barb = { .TopEdge = 0, .LeftEdge = 0, - .FrontPen = 1, //-V2568 - .BackPen = 0, //-V2568 - .DrawMode = JAM1, //-V2568 + .FrontPen = 1, + .BackPen = 0, + .DrawMode = JAM1, .NextBorder = NULL, .XY = NULL, .Count = 5 diff --git a/readme.txt b/readme.txt index cdd7311..41f0b21 100644 --- a/readme.txt +++ b/readme.txt @@ -320,8 +320,24 @@ Ketopt.h from https://github.com/attractivechaos/klib is licensed under the MIT/ SAST Tools -PVS-Studio - static analyzer for C, C++, C#, and Java code. - -Other analyzers used are: splint flawfinder cppcheck +Static analyzers used are: splint flawfinder cppcheck Check out the Makefile on how this project uses them. + +Memleak checker + +This part I find difficult to check for when compiling for a m68k target (no valgrind). + +Settled on fortify which helped me identify a memory leak. + +It can be enabled by building the source with: + + wget http://aminet.net/dev/c/fortify22.lha + lha x fortify22.lha -w=/tmp + cp /tmp/FORTIFY.CXX fortify.c + cp /tmp/UFORTIFY.H ufortify.h + cp /tmp/FORTIFY.H fortify.h + make strict=true fortify=true all + rm {uf,f}ortify* + +When running the dintwm binary on AmigaOS, some memory allocation statistics will be displayed hopefully showing no memory leaks. diff --git a/src/commodity.c b/src/commodity.c index f655931..d3d2372 100644 --- a/src/commodity.c +++ b/src/commodity.c @@ -202,7 +202,7 @@ static struct NewBroker MyBroker = COMMODITY_NAME, COMMODITY_TITLE, COMMODITY_DESC, - NBU_UNIQUE | NBU_NOTIFY, //-V2544 + NBU_UNIQUE | NBU_NOTIFY, 0, 0, 0, @@ -245,7 +245,6 @@ static short attachtooltypes(CxObj *broker, struct MsgPort *port, struct DiskObj } for (size_t i = 0; i < optarrsize ; ++i) { - //UBYTE *tt_optvalueu = FindToolType(diskobj->do_ToolTypes, (unsigned char *)defopts[i].optname); const char *tt_optvalue = (char *)FindToolType((const unsigned char **)diskobj->do_ToolTypes, (const unsigned char *)defopts[i].optname); if ((tt_optvalue) && ((strnlen(tt_optvalue, TT_MAX_LENGTH) < (size_t)TT_MAX_LENGTH))) { @@ -337,43 +336,43 @@ static short attachtooltypes(CxObj *broker, struct MsgPort *port, struct DiskObj hidewbar |= BAR_HIDE_ON; break; case BAR_TEXT_WS0_ID: - rc = rc == TRUE ? alloc_bar_item(bar_text, ws_zero, tt_optvalue) : FALSE; + rc = rc == TRUE ? assign_bar_item(bar_text, ws_zero, tt_optvalue) : FALSE; break; case BAR_TEXT_WS1_ID: - rc = rc == TRUE ? alloc_bar_item(bar_text, ws_one, tt_optvalue) : FALSE; + rc = rc == TRUE ? assign_bar_item(bar_text, ws_one, tt_optvalue) : FALSE; break; case BAR_TEXT_WS2_ID: - rc = rc == TRUE ? alloc_bar_item(bar_text, ws_two, tt_optvalue) : FALSE; + rc = rc == TRUE ? assign_bar_item(bar_text, ws_two, tt_optvalue) : FALSE; break; case BAR_TEXT_WS3_ID: - rc = rc == TRUE ? alloc_bar_item(bar_text, ws_three, tt_optvalue) : FALSE; + rc = rc == TRUE ? assign_bar_item(bar_text, ws_three, tt_optvalue) : FALSE; break; case BAR_TEXT_WS4_ID: - rc = rc == TRUE ? alloc_bar_item(bar_text, ws_four, tt_optvalue) : FALSE; + rc = rc == TRUE ? assign_bar_item(bar_text, ws_four, tt_optvalue) : FALSE; break; case BAR_TEXT_WS5_ID: - rc = rc == TRUE ? alloc_bar_item(bar_text, ws_five, tt_optvalue) : FALSE; + rc = rc == TRUE ? assign_bar_item(bar_text, ws_five, tt_optvalue) : FALSE; break; case BAR_TEXT_TILE_ID: - rc = rc == TRUE ? alloc_bar_item(bar_text, mode_tile, tt_optvalue) : FALSE; + rc = rc == TRUE ? assign_bar_item(bar_text, mode_tile, tt_optvalue) : FALSE; break; case BAR_TEXT_GRID_ID: - rc = rc == TRUE ? alloc_bar_item(bar_text, mode_grid, tt_optvalue) : FALSE; + rc = rc == TRUE ? assign_bar_item(bar_text, mode_grid, tt_optvalue) : FALSE; break; case BAR_TEXT_DWINDLE_ID: - rc = rc == TRUE ? alloc_bar_item(bar_text, mode_dwindle, tt_optvalue) : FALSE; + rc = rc == TRUE ? assign_bar_item(bar_text, mode_dwindle, tt_optvalue) : FALSE; break; case BAR_TEXT_SPIRAL_ID: - rc = rc == TRUE ? alloc_bar_item(bar_text, mode_spiral, tt_optvalue) : FALSE; + rc = rc == TRUE ? assign_bar_item(bar_text, mode_spiral, tt_optvalue) : FALSE; break; case BAR_TEXT_SEP_1_ID: - rc = rc == TRUE ? alloc_bar_item(bar_text, sep_one, tt_optvalue) : FALSE; + rc = rc == TRUE ? assign_bar_item(bar_text, sep_one, tt_optvalue) : FALSE; break; case BAR_TEXT_SEP_2_ID: - rc = rc == TRUE ? alloc_bar_item(bar_text, sep_two, tt_optvalue) : FALSE; + rc = rc == TRUE ? assign_bar_item(bar_text, sep_two, tt_optvalue) : FALSE; break; case BAR_TEXT_SPACE_ID: - rc = rc == TRUE ? alloc_bar_item(bar_text, space, tt_optvalue) : FALSE; + rc = rc == TRUE ? assign_bar_item(bar_text, space, tt_optvalue) : FALSE; break; case AUTO_ID: autotile = TRUE; @@ -402,7 +401,7 @@ static short attachtooltypes(CxObj *broker, struct MsgPort *port, struct DiskObj if (bar_text[i].text[0] != nil) { continue; } - if ((alloc_bar_item(bar_text, i, bar_default_text[i]) == FALSE)) { + if ((assign_bar_item(bar_text, i, bar_default_text[i]) == FALSE)) { return FALSE; } } @@ -438,7 +437,6 @@ static short attachtooltypes(CxObj *broker, struct MsgPort *port, struct DiskObj keys = malloc(sizeof(*keys) * keyarrsize); if (keys != NULL) { - malloc_count++; for (size_t i = 0; i < keyarrsize ; ++i) { keys[i].rawcombo = (char *)FindToolType((const unsigned char **)diskobj->do_ToolTypes, (const unsigned char *)defkeys[i].optname); @@ -466,7 +464,6 @@ static short attachtooltypes(CxObj *broker, struct MsgPort *port, struct DiskObj } free(keys); - free_count++; return rc; } @@ -476,7 +473,6 @@ short int commo(void) struct DiskObject *diskobj; unsigned char iconlib[] = "icon.library"; unsigned char diskobjname[] = "PROGDIR:dintwm"; - malloc_count++; auto_interval = (unsigned long)AUTO_INTERVAL_DELAY_DEF; @@ -494,13 +490,11 @@ short int commo(void) DeleteMsgPort(mp); return EXIT_FAILURE; } - malloc_count++; if ((subsignum = AllocSignal(-1)) == -1L) { DeleteMsgPort(mp); return EXIT_FAILURE; } - malloc_count++; mainsig = 1UL << (unsigned long)mainsignum; subsig = 1UL << (unsigned long)subsignum; @@ -512,7 +506,6 @@ short int commo(void) MyBroker.nb_Port = mp; broker = CxBroker(&MyBroker, NULL); - malloc_count++; if (broker == NULL) { FreeSignal(mainsignum); @@ -551,7 +544,6 @@ short int commo(void) } if (vws_on == TRUE) { - //(void)countwindows(LOCK, 1); (void)countwindows(LOCK); getactive(); if (backdropped == TRUE) { @@ -570,7 +562,6 @@ short int commo(void) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" subtask = CreateTask(subactionchkname, 0L, (void *)subactionchk, 2048L); // -V2590 - malloc_count++; #pragma GCC diagnostic pop if(subtask == NULL) { running = FALSE; @@ -579,7 +570,6 @@ short int commo(void) //Main Loop while (running == TRUE) { - //winnum_start = countwindows(NOLOCK, ASSIGN); winnum_start = countwindows(NOLOCK); wakeupsigs = Wait((mainsig) | (1UL << mp->mp_SigBit)); @@ -592,7 +582,6 @@ short int commo(void) if (tile_off == FALSE) { running = defkeys[*current_layout].func(&defkeys[*current_layout].arg); update_wbar(); - //winnum_start = countwindows(NOLOCK, NOASSIGN); winnum_start = countwindows(NOLOCK); } Signal(subtask, subsig); @@ -603,9 +592,9 @@ short int commo(void) long id = CxMsgID(msg); unsigned long type = CxMsgType(msg); - ReplyMsg((struct Message *)msg); //-V2545 + ReplyMsg((struct Message *)msg); - if (type == (unsigned long)CXM_COMMAND) //-V2544 + if (type == (unsigned long)CXM_COMMAND) { switch (id) { @@ -630,7 +619,7 @@ short int commo(void) // Do nothing break; } - } else if (type == (unsigned long)CXM_IEVENT) { //-V2544 + } else if (type == (unsigned long)CXM_IEVENT) { if (id <= (TILE_FUNC_LIMIT)) { *current_layout = id; } @@ -648,14 +637,12 @@ short int commo(void) } DeleteCxObjAll(broker); - free_count++; while ((msg = (void *)GetMsg(mp)) != NULL) { - ReplyMsg((struct Message *)msg); //-V2545 + ReplyMsg((struct Message *)msg); } } DeleteMsgPort(mp); - free_count++; } cleanup(); @@ -704,13 +691,12 @@ static void free_opts(void) } } -static short alloc_bar_item(Bar_Text *b, enum bar_texts x, const char *c) +static short assign_bar_item(Bar_Text *b, enum bar_texts x, const char *c) { int res = snprintf((char *)b[x].text, TT_MAX_LENGTH, "%s", c); if (res < 0) { return FALSE; } - return TRUE; } @@ -766,7 +752,6 @@ static void subactionchk(void) if (running == FALSE) { delete_timer(tr); - free_count++; Signal(maintask, mainsig); (void)Wait(0L); } @@ -785,28 +770,25 @@ struct timerequest *create_timer(unsigned long unit) timerport = CreatePort(0, 0); if (timerport == NULL) { - return (NULL); + return NULL; } TimerIO = - (struct timerequest *)CreateExtIO(timerport, //-V2545 + (struct timerequest *)CreateExtIO(timerport, sizeof(struct timerequest)); - malloc_count++; - if (TimerIO == NULL) { DeletePort(timerport); /* Delete message port */ - return (NULL); + return NULL; } - error = OpenDevice(tdevice, unit, (struct IORequest *)TimerIO, 0L); //-V2545 + error = OpenDevice(tdevice, unit, (struct IORequest *)TimerIO, 0L); if ((int)error != 0) { delete_timer(TimerIO); - free_count++; - return (NULL); + return NULL; } - return (TimerIO); + return TimerIO; } void time_delay(struct timerequest *tr, const struct timeval *tv) { @@ -817,7 +799,7 @@ void time_delay(struct timerequest *tr, const struct timeval *tv) { tr->tr_time = *tv; /* post request to the timer -- will go to sleep till done */ - (void)DoIO((struct IORequest *)tr); //-V2545 + (void)DoIO((struct IORequest *)tr); } void delete_timer(struct timerequest *tr) { @@ -833,8 +815,8 @@ void delete_timer(struct timerequest *tr) { AbortIO((struct IORequest *)tr); /* Ask device to abort any pending requests */ } (void)WaitIO((struct IORequest *)tr); /* Clean up */ - CloseDevice((struct IORequest *)tr); //-V2545 - DeleteExtIO((struct IORequest *)tr); //-V2545 + CloseDevice((struct IORequest *)tr); + DeleteExtIO((struct IORequest *)tr); } } diff --git a/src/dintwm.c b/src/dintwm.c index d287677..313693d 100644 --- a/src/dintwm.c +++ b/src/dintwm.c @@ -8,14 +8,10 @@ short tile_off = FALSE; // Bar definitions unsigned int hidewbar = 0U; unsigned char nil = (unsigned char)'\0'; -//Bar_Text *bar_text; -//Bar_Color bar_color[BAR_LAST_COLOR]; int wbarheight = 0; short bar_on = FALSE; short vws_on = FALSE; enum ws_num current_ws; -int malloc_count = 0; -int free_count = 0; int main(int argc, char **argv) { @@ -29,6 +25,11 @@ int main(int argc, char **argv) dint_exit_state = dintwmrun(argc, argv); + #ifdef FORTIFY + Fortify_LeaveScope(); + Fortify_OutputStatistics(); + #endif + return dint_exit_state; } @@ -602,16 +603,15 @@ short docmd(const Arg * arg) } if ((file = Open(conline, MODE_NEWFILE)) != 0L) { - // Will not fix MISRA warnings from amiga NDK - stags[0].ti_Tag = SYS_Input; //-V2544 //-V2568 + stags[0].ti_Tag = SYS_Input; stags[0].ti_Data = (long unsigned int)file; - stags[1].ti_Tag = SYS_Output; //-V2544 //-V2568 - stags[1].ti_Data = 0; //-V2568 - stags[2].ti_Tag = SYS_Asynch; //-V2544 //-V2568 - stags[2].ti_Data = TRUE; //-V2568 - stags[3].ti_Tag = SYS_UserShell; //-V2544 //-V2568 - stags[3].ti_Data = TRUE; //-V2568 - stags[4].ti_Tag = TAG_DONE; //-V2568 + stags[1].ti_Tag = SYS_Output; + stags[1].ti_Data = 0; + stags[2].ti_Tag = SYS_Asynch; + stags[2].ti_Data = TRUE; + stags[3].ti_Tag = SYS_UserShell; + stags[3].ti_Data = TRUE; + stags[4].ti_Tag = TAG_DONE; if ((SystemTagList(cmd, stags)) == -1) { unsigned char dcwarn[] = "Custom CMD/CONLINE is not correct. Quitting"; @@ -838,19 +838,19 @@ static unsigned char * padwbartext(Bar_Text *b, enum bar_texts x) short init_wbar(void) { struct TagItem tagitem[7]; - tagitem[0].ti_Tag = WA_Width; //-V2544 //-V2568 + tagitem[0].ti_Tag = WA_Width; tagitem[0].ti_Data = (unsigned long)swidth - ((unsigned long)leftgap + (unsigned long)rightgap); - tagitem[1].ti_Tag = WA_Height; //-V2544 //-V2568 + tagitem[1].ti_Tag = WA_Height; tagitem[1].ti_Data = (unsigned long)wbarheight; - tagitem[2].ti_Tag = WA_Top; //-V2544 //-V2568 + tagitem[2].ti_Tag = WA_Top; tagitem[2].ti_Data = ((unsigned long)sheight - (unsigned long)bottomgap); - tagitem[3].ti_Tag = WA_Borderless; //-V2544 //-V2568 - tagitem[3].ti_Data = 1; //-V2568 - tagitem[4].ti_Tag = WA_SmartRefresh; //-V2544 //-V2568 - tagitem[4].ti_Data = 1; //-V2568 - tagitem[5].ti_Tag = WA_IDCMP; //-V2544 //-V2568 - tagitem[5].ti_Data = IDCMP_REFRESHWINDOW|IDCMP_CHANGEWINDOW; //-V2544 //-V2568 - tagitem[6].ti_Tag = TAG_DONE; //-V2544 //-V2568 + tagitem[3].ti_Tag = WA_Borderless; + tagitem[3].ti_Data = 1; + tagitem[4].ti_Tag = WA_SmartRefresh; + tagitem[4].ti_Data = 1; + tagitem[5].ti_Tag = WA_IDCMP; + tagitem[5].ti_Data = IDCMP_REFRESHWINDOW|IDCMP_CHANGEWINDOW; + tagitem[6].ti_Tag = TAG_DONE; lockbasescreen(&ilock, &screen); wbw = OpenWindowTagList(NULL, tagitem); @@ -1005,7 +1005,7 @@ void wbarcwb(void) { (void)WaitPort(wbw->UserPort); while ((msg = (struct IntuiMessage *)GetMsg(wbw->UserPort)) != NULL) { if (msg->Class == (unsigned long)IDCMP_SIZEVERIFY) { - ReplyMsg((struct Message *)msg); //-V2545 + ReplyMsg((struct Message *)msg); } } } @@ -1115,30 +1115,30 @@ short info_window(unsigned char * info_text) .TopEdge = 0, .LeftEdge = 0, .ITextFont = NULL, - .DrawMode = JAM2, //-V2568 - .FrontPen = 1, //-V2568 - .BackPen = 2, //-V2568 + .DrawMode = JAM2, + .FrontPen = 1, + .BackPen = 2, .IText = info_text, .NextText = NULL }; - tagitem[0].ti_Tag = WA_Width; //-V2544 //-V2568 - tagitem[0].ti_Data = 100; //-V2544 //-V2568 - tagitem[1].ti_Tag = WA_Height; //-V2544 //-V2568 - tagitem[1].ti_Data = 50; //-V2544 //-V2568 - tagitem[2].ti_Tag = WA_Top; //-V2544 //-V2568 + tagitem[0].ti_Tag = WA_Width; + tagitem[0].ti_Data = 100; + tagitem[1].ti_Tag = WA_Height; + tagitem[1].ti_Data = 50; + tagitem[2].ti_Tag = WA_Top; tagitem[2].ti_Data = (unsigned long)((unsigned long)sheight / 2UL); - tagitem[3].ti_Tag = WA_SimpleRefresh; //-V2544 //-V2568 - tagitem[3].ti_Data = 1; //-V2568 - tagitem[4].ti_Tag = WA_IDCMP; //-V2544 //-V2568 - tagitem[4].ti_Data = IDCMP_CLOSEWINDOW; //-V2568 - tagitem[5].ti_Tag = WA_Flags; //-V2544 //-V2568 - tagitem[5].ti_Data = WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_ACTIVATE; //-V2544 //-V2568 - tagitem[6].ti_Tag = WA_Title; //-V2544 //-V2568 - tagitem[6].ti_Data = (unsigned long)"Dintwm Info"; //-V2568 - tagitem[7].ti_Tag = WA_Left; //-V2544 //-V2568 - tagitem[7].ti_Data = (unsigned long)(((unsigned long)swidth / 2UL) - 150UL); //-V2568 - tagitem[8].ti_Tag = TAG_DONE; //-V2544 //-V2568 + tagitem[3].ti_Tag = WA_SimpleRefresh; + tagitem[3].ti_Data = 1; + tagitem[4].ti_Tag = WA_IDCMP; + tagitem[4].ti_Data = IDCMP_CLOSEWINDOW; + tagitem[5].ti_Tag = WA_Flags; + tagitem[5].ti_Data = WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_ACTIVATE; + tagitem[6].ti_Tag = WA_Title; + tagitem[6].ti_Data = (unsigned long)"Dintwm Info"; + tagitem[7].ti_Tag = WA_Left; + tagitem[7].ti_Data = (unsigned long)(((unsigned long)swidth / 2UL) - 150UL); + tagitem[8].ti_Tag = TAG_DONE; lockbasescreen(&ilock, &screen); @@ -1150,10 +1150,10 @@ short info_window(unsigned char * info_text) } info_text_length = TextLength(twin->RPort, info_text, strnlen((const char *)info_text, TT_MAX_LENGTH)); tleft = (unsigned long)info_text_length + (unsigned long)twin->BorderLeft + (unsigned long)twin->BorderRight; - tagitem[0].ti_Tag = WA_Width; //-V2544 //-V2568 - tagitem[0].ti_Data = tleft; //-V2544 //-V2568 - tagitem[7].ti_Tag = WA_Left; //-V2544 //-V2568 - tagitem[7].ti_Data = (unsigned long)((unsigned long)swidth / 2UL) - (unsigned long)((unsigned long)tleft / 2UL); //-V2568 + tagitem[0].ti_Tag = WA_Width; + tagitem[0].ti_Data = tleft; + tagitem[7].ti_Tag = WA_Left; + tagitem[7].ti_Data = (unsigned long)((unsigned long)swidth / 2UL) - (unsigned long)((unsigned long)tleft / 2UL); CloseWindow(twin); // End hack @@ -1178,7 +1178,7 @@ short info_window(unsigned char * info_text) struct IntuiMessage *msg; (void)Wait(1UL << iwin->UserPort->mp_SigBit); msg = (struct IntuiMessage *)GetMsg(iwin->UserPort); - ReplyMsg((struct Message *)msg); //-V2545 + ReplyMsg((struct Message *)msg); if (msg->Class == (unsigned long)IDCMP_CLOSEWINDOW) { CloseWindow(iwin); closewin = TRUE; @@ -1202,9 +1202,4 @@ int modululator(unsigned long w) void clean_winfo(void) { free(winfo); - free_count++; - #ifdef FORTIFY - Fortify_LeaveScope(); - Fortify_OutputStatistics(); - #endif }