Date: Tue, 5 Jan 2010 20:53:55 +0000 (UTC) From: David Malone <dwmalone@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r201610 - head/usr.bin/xlint/xlint Message-ID: <201001052053.o05Krtmh010089@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dwmalone Date: Tue Jan 5 20:53:55 2010 New Revision: 201610 URL: http://svn.freebsd.org/changeset/base/201610 Log: 1) Make usage() as dead2 - it helps the compiler know that some vars are not used uninitialised. 2) Fix some constness problems. 3) Avoid a signedness problem by casting to size_t. If bn != stuff, than stuff-1-bn should be > 0. Modified: head/usr.bin/xlint/xlint/xlint.c Modified: head/usr.bin/xlint/xlint/xlint.c ============================================================================== --- head/usr.bin/xlint/xlint/xlint.c Tue Jan 5 20:42:25 2010 (r201609) +++ head/usr.bin/xlint/xlint/xlint.c Tue Jan 5 20:53:55 2010 (r201610) @@ -135,7 +135,7 @@ static char *concat3(const char *, const static void terminate(int) __attribute__((__noreturn__)); static const char *lbasename(const char *, int); static void appdef(char ***, const char *); -static void usage(void); +static void usage(void) __dead2; static void fname(const char *); static void runchild(const char *, char *const *, const char *, int); static void findlibs(char *const *); @@ -304,11 +304,12 @@ int main(int argc, char *argv[]) { int c; - char flgbuf[3], *tmp, *s; + char flgbuf[3], *s; + const char *tmp; size_t len; if ((tmp = getenv("TMPDIR")) == NULL || (len = strlen(tmp)) == 0) { - tmpdir = xstrdup(_PATH_TMP); + tmpdir = _PATH_TMP; } else { s = xmalloc(len + 2); (void)sprintf(s, "%s%s", tmp, tmp[len - 1] == '/' ? "" : "/"); @@ -555,9 +556,9 @@ main(int argc, char *argv[]) terminate(0); if (!oflag) { - if ((s = getenv("LIBDIR")) == NULL || strlen(s) == 0) - s = PATH_LINTLIB; - appcstrg(&libsrchpath, s); + if ((tmp = getenv("LIBDIR")) == NULL || strlen(tmp) == 0) + tmp = PATH_LINTLIB; + appcstrg(&libsrchpath, tmp); findlibs(libs); findlibs(deflibs); } @@ -620,7 +621,7 @@ fname(const char *name) return; } ofn = xmalloc(strlen(bn) + (bn == suff ? 4 : 2)); - len = bn == suff ? strlen(bn) : (suff - 1) - bn; + len = bn == suff ? strlen(bn) : (size_t)((suff - 1) - bn); (void)sprintf(ofn, "%.*s", (int)len, bn); (void)strcat(ofn, ".ln"); } else {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001052053.o05Krtmh010089>