chiark / gitweb /
checkpath.c: Mark the `root' node explicitly as constant.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 16 Jul 2024 13:01:40 +0000 (14:01 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 17 Jul 2024 12:23:10 +0000 (13:23 +0100)
It never actually changes, but this isn't clear from the typing.

checkpath.c

index 4cf5181ddc1d19ce82cb22151ecf5d857090438e..5d77b180384a966c95ffa53e22c350c9e3a6bf9a 100644 (file)
@@ -68,7 +68,7 @@ struct elt {
 
 /*----- Static variables --------------------------------------------------*/
 
 
 /*----- Static variables --------------------------------------------------*/
 
-static struct elt rootnode = { 0, 0, 0 }; /* Root of the list */
+static const struct elt rootnode = { 0, 0, 0 }; /* Root of the list */
 static struct elt *sp;                 /* Stack pointer for list */
 static dstr d = DSTR_INIT;             /* Current path string */
 
 static struct elt *sp;                 /* Stack pointer for list */
 static dstr d = DSTR_INIT;             /* Current path string */
 
@@ -353,7 +353,7 @@ unsigned checkpath(const char *p, const struct checkpath *cp)
 
   /* --- Initialize stack pointer and path string --- */
 
 
   /* --- Initialize stack pointer and path string --- */
 
-  sp = &rootnode;
+  sp = (/*unconst*/ struct elt *)&rootnode;
   dstr_destroy(&d);
 
   /* --- Try to find the current directory --- */
   dstr_destroy(&d);
 
   /* --- Try to find the current directory --- */