From: Mark Wooding Date: Tue, 16 Jul 2024 13:01:40 +0000 (+0100) Subject: checkpath.c: Mark the `root' node explicitly as constant. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/checkpath/commitdiff_plain/822843636382a01a10f4c7c6eb704ef2ec5218ad?ds=sidebyside checkpath.c: Mark the `root' node explicitly as constant. It never actually changes, but this isn't clear from the typing. --- diff --git a/checkpath.c b/checkpath.c index 4cf5181..5d77b18 100644 --- a/checkpath.c +++ b/checkpath.c @@ -68,7 +68,7 @@ struct elt { /*----- 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 */ @@ -353,7 +353,7 @@ unsigned checkpath(const char *p, const struct checkpath *cp) /* --- Initialize stack pointer and path string --- */ - sp = &rootnode; + sp = (/*unconst*/ struct elt *)&rootnode; dstr_destroy(&d); /* --- Try to find the current directory --- */