diff options
author | dwmalone <dwmalone@FreeBSD.org> | 2010-01-05 20:53:55 +0000 |
---|---|---|
committer | dwmalone <dwmalone@FreeBSD.org> | 2010-01-05 20:53:55 +0000 |
commit | ca1f8c06cee91352273fe0335f0ea576905d3238 (patch) | |
tree | 671b29a3b18d3237cf557d85956170cfce5c913d /usr.bin/xlint | |
parent | 2dd11a3eaaa7e7f9ee8766d13f00bfef1766ff90 (diff) | |
download | FreeBSD-src-ca1f8c06cee91352273fe0335f0ea576905d3238.zip FreeBSD-src-ca1f8c06cee91352273fe0335f0ea576905d3238.tar.gz |
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.
Diffstat (limited to 'usr.bin/xlint')
-rw-r--r-- | usr.bin/xlint/xlint/xlint.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/usr.bin/xlint/xlint/xlint.c b/usr.bin/xlint/xlint/xlint.c index 82a118e..553ac19 100644 --- a/usr.bin/xlint/xlint/xlint.c +++ b/usr.bin/xlint/xlint/xlint.c @@ -135,7 +135,7 @@ static char *concat3(const char *, const char *, const char *); 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 { |