diff options
author | yar <yar@FreeBSD.org> | 2008-01-29 17:50:29 +0000 |
---|---|---|
committer | yar <yar@FreeBSD.org> | 2008-01-29 17:50:29 +0000 |
commit | 050f1fe2976b266b02140b04a20f11259ebcd949 (patch) | |
tree | 7157124c00dbd32acbb239d5d0205d1222f04309 | |
parent | 5290562b54a79867037d93fef3eec3c33805a0e8 (diff) | |
download | FreeBSD-src-050f1fe2976b266b02140b04a20f11259ebcd949.zip FreeBSD-src-050f1fe2976b266b02140b04a20f11259ebcd949.tar.gz |
An average consumer of fts(3) that avoids keeping pointers to old
FTSENTs and uses only what fts_read() has just returned can rely
on fts_path being NUL-terminated. Under these conditions, a plain
vanilla "%s" format can be safely used to printf an fts_path.
OK'ed by: rwatson
-rw-r--r-- | usr.sbin/setfmac/setfmac.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/usr.sbin/setfmac/setfmac.c b/usr.sbin/setfmac/setfmac.c index fab2a66..e3da25d 100644 --- a/usr.sbin/setfmac/setfmac.c +++ b/usr.sbin/setfmac/setfmac.c @@ -156,13 +156,11 @@ main(int argc, char **argv) case FTS_W: /* do whiteout */ if (apply_specs(specs, ftsent, hflag, vflag)) { if (eflag) { - errx(1, "labeling not supported in " - "%.*s", (int) ftsent->fts_pathlen, + errx(1, "labeling not supported in %s", ftsent->fts_path); } if (!qflag) - warnx("labeling not supported in %.*s", - (int) ftsent->fts_pathlen, + warnx("labeling not supported in %s", ftsent->fts_path); fts_set(fts, ftsent, FTS_SKIP); } @@ -170,12 +168,10 @@ main(int argc, char **argv) case FTS_DNR: /* die on all errors */ case FTS_ERR: case FTS_NS: - err(1, "traversing %.*s", (int) ftsent->fts_pathlen, - ftsent->fts_path); + err(1, "traversing %s", ftsent->fts_path); default: - errx(1, "CANNOT HAPPEN (%d) traversing %.*s", - ftsent->fts_info, (int) ftsent->fts_pathlen, - ftsent->fts_path); + errx(1, "CANNOT HAPPEN (%d) traversing %s", + ftsent->fts_info, ftsent->fts_path); } } fts_close(fts); @@ -438,8 +434,7 @@ apply_specs(struct label_specs *specs, FTSENT *ftsent, int hflag, int vflag) ls->match = ent; if (vflag) { if (matchedby == 0) { - printf("%.*s matched by ", - (int) ftsent->fts_pathlen, + printf("%s matched by ", ftsent->fts_path); matchedby = 1; } @@ -483,8 +478,7 @@ apply_specs(struct label_specs *specs, FTSENT *ftsent, int hflag, int vflag) free(macstr); return (1); } - err(1, "mac_set_link(%.*s, %s)", (int) ftsent->fts_pathlen, - ftsent->fts_path, macstr); + err(1, "mac_set_link(%s, %s)", ftsent->fts_path, macstr); } mac_free(mac); free(macstr); |