From: "Todd C. Miller" Subject: Re: use size_t for loop indices to avoid signedness warnings To: Stefan Sperling Cc: Ed Maste , gameoftrees@openbsd.org Date: Fri, 18 Dec 2020 08:54:33 -0700 Something I find useful is a macro like the following: /* sizeof() that returns a signed value */ #define ssizeof(_x) ((ssize_t)sizeof(_x)) Then I just use ssizeof(foo) when I need to compare against a signed integer. Opinions vary on whether it is better to hide the cast or not in this way :-) - todd