From 8c653212c0e6d15997e4217a514301f5682a41c4 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sun, 18 Feb 2018 10:38:49 -0300 Subject: Replace size_t with int/void* union I was occasionally passing negative values to size_t. Plus, this better reflects the intent of the variant argument. Reported by Coverity: https://scan8.coverity.com/reports.htm#v13253/p10402/fileInstanceId=22093891&defectInstanceId=7543346&mergedDefectId=174179&fileStart=251&fileEnd=500 --- MainPanel.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'MainPanel.c') diff --git a/MainPanel.c b/MainPanel.c index b5a7e305..25023367 100644 --- a/MainPanel.c +++ b/MainPanel.c @@ -25,7 +25,12 @@ typedef struct MainPanel_ { pid_t pidSearch; } MainPanel; -typedef bool(*MainPanel_ForeachProcessFn)(Process*, size_t); +typedef union { + int i; + void* v; +} Arg; + +typedef bool(*MainPanel_ForeachProcessFn)(Process*, Arg); #define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar) @@ -148,7 +153,7 @@ const char* MainPanel_getValue(MainPanel* this, int i) { return ""; } -bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, size_t arg, bool* wasAnyTagged) { +bool MainPanel_foreachProcess(MainPanel* this, MainPanel_ForeachProcessFn fn, Arg arg, bool* wasAnyTagged) { Panel* super = (Panel*) this; bool ok = true; bool anyTagged = false; -- cgit v1.2.3