Description: Fix compiler warnings for uninitialized variables
 This patch fixes several compiler warnings that appear with modern GCC versions:
 - Fixes duplicate assignment of dprint.G in diff.c and fspy.c
 - Fixes uninitialized variable warning in adaptive.c (adaptive_delete)
 - Fixes uninitialized variable warning in enumdirs.c (recwrap)
 - Fixes uninitialized pointer warnings in diff.c, output.c, and stating.c (freeme)
 - Fixes format specifier warnings for sizeof() in debug prints (%i -> %li)
 - Fixes type mismatch for max_element_count (unsigned int -> int)
 - Fixes type mismatch for inotify watch descriptors (int vs unsigned int)
 - Adds proper function prototypes to enumdirs.h
Author: Bean Huo <beanhuo@micron.com>
Forwarded: no
Last-Update: 2025-11-11

diff --git a/src/adaptive.c b/src/adaptive.c
index 3a467f8..374ef14 100644
--- a/src/adaptive.c
+++ b/src/adaptive.c
@@ -42,7 +42,7 @@
 #include "enumdirs.h" /* needed for max_element_count */
 #include "stating.h"
 
-extern unsigned int max_element_count; /* from enumdirs.c */
+extern int max_element_count; /* from enumdirs.c */
 extern unsigned int elc_oa; /* from enumdirs.c */
 
 unsigned int *free_wds; /* holds the freed wds - faster reuse */
@@ -70,7 +70,8 @@ void init_free_wds(unsigned int fdin) {
 
 void adaptive_add(const char *path, struct felement *lsptr, struct stat *statdat) {
 
-  unsigned int wd, i, id = UINT_MAX;
+  unsigned int i, id = UINT_MAX;
+  int wd;
 
   if(isdir(path, statdat) != TRUE)
     return;
@@ -106,7 +107,7 @@ void adaptive_delete(const char *path, struct felement *lsptr, unsigned int wd)
   if(wd == 1) /* dirty workaround! */
     return;
 
-  unsigned int i, id;
+  unsigned int i, id = UINT_MAX;
 
   /* getting the element id */
   for(i=0; i <= elc_oa; i++) {
diff --git a/src/diff.c b/src/diff.c
index 5b796ef..c656a76 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -56,7 +56,7 @@ unsigned int delc_oa = 0;
 
 struct festat *init_diff(void) {
 
-  dprint.s = dprint.A = dprint.M = dprint.S = dprint.O = dprint.U = dprint.G = dprint.G = dprint.I = dprint.D = 0;
+  dprint.s = dprint.A = dprint.M = dprint.S = dprint.O = dprint.U = dprint.G = dprint.I = dprint.D = 0;
 
   if((felsptr = (struct festat *) malloc(DIFF_ELEMENT_INIT_COUNT * sizeof(struct festat))) == NULL) {
     fprintf(stderr, "ERROR: could not allocate mem for initial festat list!\n");
@@ -78,7 +78,7 @@ struct festat *extend_diff_list(struct festat *felsptr) {
   } 
 
 #ifdef _DEBUG
-  printf("EXTEND_DIFF_LIST: %i (%i)\n", delc_oa + DIFF_ELEMENT_INIT_COUNT, (delc_oa + DIFF_ELEMENT_INIT_COUNT) * sizeof(struct festat));
+  printf("EXTEND_DIFF_LIST: %i (%li)\n", delc_oa + DIFF_ELEMENT_INIT_COUNT, (delc_oa + DIFF_ELEMENT_INIT_COUNT) * sizeof(struct festat));
 #endif
 
   return felsptr;
@@ -91,7 +91,7 @@ void diffing(char *fpath, struct stat *statdat, struct diffprint *dprintptr, cha
   char mychar;
   char *freeme;
 
-  unsigned int i, id;
+  unsigned int i;
 
 #ifdef _DEBUG
   printf("DIFFING: %s\n", fpath);
@@ -99,13 +99,11 @@ void diffing(char *fpath, struct stat *statdat, struct diffprint *dprintptr, cha
 
   /* getting the element id */
   for(i=0; i <= delc_oa; i++) {
-    if(strcmp(felsptr[i].path, fpath) == 0) {
-      id = felsptr[i].id;
+    if(strcmp(felsptr[i].path, fpath) == 0)
       break;
-    }
   }
 
-  mystrin_tmp = strdup(diffstring);
+  freeme = mystrin_tmp = strdup(diffstring);
 
   while((mystr = strtok(mystrin_tmp, DELIM))) {
     if(strlen(mystr) == 1) {
diff --git a/src/enumdirs.c b/src/enumdirs.c
index 055eb10..f5b956e 100644
--- a/src/enumdirs.c
+++ b/src/enumdirs.c
@@ -52,7 +52,7 @@ extern char *ifilterstring; /* from fspy.c */
 extern unsigned int delc_oa; /* from diff.c */
 extern struct festat *felsptr; /* from diff.c */
 
-unsigned int max_element_count = 0; /* maximum number of elements */
+int max_element_count = 0; /* maximum number of elements */
 unsigned int elc_oa = 0; /* over all element counter */
 
 /* ATTENTION: the max num. of elements must not be greater than /proc/sys/fs/inotify/max_user_watches */
@@ -97,7 +97,7 @@ struct felement *extend_list(struct felement *lsptr) {
   } 
 
 #ifdef _DEBUG
-  printf("EXTEND_LIST: %i (%i)\n", elc_oa + ELEMENT_INIT_COUNT, (elc_oa + ELEMENT_INIT_COUNT) * sizeof(struct felement));
+  printf("EXTEND_LIST: %i (%li)\n", elc_oa + ELEMENT_INIT_COUNT, (elc_oa + ELEMENT_INIT_COUNT) * sizeof(struct felement));
 #endif
 
   return lsptr;
@@ -215,7 +215,7 @@ struct felement *recwrap(char *initial_path, int recursive_depth, struct stat *s
   int recnt; /* temp. recusrion counter */
   int base, sticky, elc_oa_sticky; /* helper -> placemark */
   struct felement *lsptr;
-  struct festat *felsptr;
+  struct festat *felsptr = NULL;
 
   lsptr = init_list();
   if(diffstring != NULL) {
diff --git a/src/enumdirs.h b/src/enumdirs.h
index 7991be9..6e5e8e5 100644
--- a/src/enumdirs.h
+++ b/src/enumdirs.h
@@ -31,17 +31,18 @@
 #ifndef _ENUMDIRS_H
 #define _ENUMDIRS_H
 
-#include "fspy.h"
-
 #define ELEMENT_SIZE              1024
 #define ELEMENT_INIT_COUNT        1024
 #define DIFF_ELEMENT_INIT_COUNT   2048
 
 #define NO_DIR                    NULL
 
+/* Forward declarations to avoid circular dependency */
+struct felement;
+struct stat;
+
 int grab_max_element_count(void);
-int pathlookup();
-//struct felement *recwrap();
+int pathlookup(char *lpath, unsigned int wd, struct felement *lsptr);
 struct felement *recwrap(char *initial_path, int recursive_depth, struct stat *statdat);
 
 #endif
diff --git a/src/fspy.c b/src/fspy.c
index f6f3d90..833e019 100644
--- a/src/fspy.c
+++ b/src/fspy.c
@@ -53,7 +53,7 @@
 /* setting the sig_exit check var. */
 volatile sig_atomic_t sigint = 1;
 
-extern unsigned int max_element_count; /* from enumdirs.c */
+extern int max_element_count; /* from enumdirs.c */
 extern unsigned int elc_oa; /* from enumdirs.c */
 extern char twhitelst[]; /* from stating.c */
 extern char dbasewhitelist[]; /* from diff.c */
@@ -157,7 +157,8 @@ static void my_sig_handle(int sig) {
 
 int main(int argc, char **argv) {
 
-  unsigned int fd, wd, cnt = 0, len = 0, i = 0;
+  int fd, wd, len = 0;
+  unsigned int cnt = 0, i = 0;
   char    buf[BUF_LEN], *path, *lpath = NULL;
   char    pbuf[EVENT_SIZE + 4096];
   char    fpath[ELEMENT_SIZE * 2] = {0};
@@ -244,7 +245,7 @@ int main(int argc, char **argv) {
 
   /* check the given recursive depth */
   if(tmp_recursive_depth != NULL) {
-    if(isnumber(tmp_recursive_depth) == TRUE && strlen(tmp_recursive_depth) < (numlen(MAXRECURDEPTH) + 1)) {
+    if(isnumber(tmp_recursive_depth) == TRUE && strlen(tmp_recursive_depth) < (long unsigned int)(numlen(MAXRECURDEPTH) + 1)) {
       recursive_depth = atoi(tmp_recursive_depth);
       if(recursive_depth < MINRECURDEPTH || recursive_depth > MAXRECURDEPTH) {
         fprintf(stderr, "ERROR: value of argument '-R/--recursive' needs to be a number between %i and %i!\n", MINRECURDEPTH, MAXRECURDEPTH);
@@ -470,7 +471,7 @@ int main(int argc, char **argv) {
           if(adaptive == TRUE)
             adaptive_check(event->mask, fpath, lsptr, statdat, event->wd);
           if(diffstring != NULL) {
-            dprint.s = dprint.A = dprint.M = dprint.S = dprint.O = dprint.U = dprint.G = dprint.G = dprint.I = dprint.D = 0;
+            dprint.s = dprint.A = dprint.M = dprint.S = dprint.O = dprint.U = dprint.G = dprint.I = dprint.D = 0;
             diffing(fpath, statdat, &dprint, diffstring);
           }
           /* TODO: change print_data to use fpath instead of lpath and assembling the fqp on its own */
diff --git a/src/output.c b/src/output.c
index 47c28f4..320d8e2 100644
--- a/src/output.c
+++ b/src/output.c
@@ -60,7 +60,7 @@ void print_data(char *mystrin, struct inotify_event *event, const char *event_fp
   
   snprintf(fpath, (ELEMENT_SIZE * 2), "%s%s", event_fpath, event->name);
 
-  mystrin_tmp = strdup(mystrin);
+  freeme = mystrin_tmp = strdup(mystrin);
 
   while((mystr = strtok(mystrin_tmp, DELIM))) {
     if(strlen(mystr) == 1) {
diff --git a/src/stating.c b/src/stating.c
index 9e2acb9..ffceb49 100644
--- a/src/stating.c
+++ b/src/stating.c
@@ -94,7 +94,7 @@ int checktype(const char *event_fpath, struct inotify_event *event, char *tstrin
     snprintf(fpath, (ELEMENT_SIZE * 2), "%s%s", event_fpath, event->name);
   }
 
-  tstring_tmp = strdup(tstring);
+  freeme = tstring_tmp = strdup(tstring);
 
   if(statdat == NULL) {
     if(statit(fpath, &sb) != TRUE) {
