From 0e72f5fb83f80e4ab61c889b9cdb27bcf1b40e96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Thu, 9 Dec 2021 23:50:41 +0100 Subject: [PATCH] libzfs: diff: simplify superfluous stdio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Reviewed-by: Rich Ercolani Signed-off-by: Ahelenia ZiemiaƄska Closes #12829 --- lib/libzfs/libzfs_diff.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/libzfs/libzfs_diff.c b/lib/libzfs/libzfs_diff.c index 77b9da6aad..8884ac536a 100644 --- a/lib/libzfs/libzfs_diff.c +++ b/lib/libzfs/libzfs_diff.c @@ -51,9 +51,9 @@ #define ZDIFF_PREFIX "zfs-diff-%d" #define ZDIFF_ADDED '+' -#define ZDIFF_MODIFIED 'M' +#define ZDIFF_MODIFIED "M" #define ZDIFF_REMOVED '-' -#define ZDIFF_RENAMED 'R' +#define ZDIFF_RENAMED "R" /* @@ -180,16 +180,13 @@ print_rename(FILE *fp, differ_info_t *di, const char *old, const char *new, (void) fprintf(fp, "%10lld.%09lld\t", (longlong_t)isb->zs_ctime[0], (longlong_t)isb->zs_ctime[1]); - (void) fprintf(fp, "%c\t", ZDIFF_RENAMED); + (void) fputs(ZDIFF_RENAMED "\t", fp); if (di->classify) (void) fprintf(fp, "%c\t", get_what(isb->zs_mode)); print_cmn(fp, di, old); - if (di->scripted) - (void) fprintf(fp, "\t"); - else - (void) fprintf(fp, " -> "); + (void) fputs(di->scripted ? "\t" : " -> ", fp); print_cmn(fp, di, new); - (void) fprintf(fp, "\n"); + (void) fputc('\n', fp); } static void @@ -200,12 +197,11 @@ print_link_change(FILE *fp, differ_info_t *di, int delta, const char *file, (void) fprintf(fp, "%10lld.%09lld\t", (longlong_t)isb->zs_ctime[0], (longlong_t)isb->zs_ctime[1]); - (void) fprintf(fp, "%c\t", ZDIFF_MODIFIED); + (void) fputs(ZDIFF_MODIFIED "\t", fp); if (di->classify) (void) fprintf(fp, "%c\t", get_what(isb->zs_mode)); print_cmn(fp, di, file); - (void) fprintf(fp, "\t(%+d)", delta); - (void) fprintf(fp, "\n"); + (void) fprintf(fp, "\t(%+d)\n", delta); } static void @@ -220,7 +216,7 @@ print_file(FILE *fp, differ_info_t *di, char type, const char *file, if (di->classify) (void) fprintf(fp, "%c\t", get_what(isb->zs_mode)); print_cmn(fp, di, file); - (void) fprintf(fp, "\n"); + (void) fputc('\n', fp); } static int @@ -313,7 +309,7 @@ write_inuse_diffs_one(FILE *fp, differ_info_t *di, uint64_t dobj) print_link_change(fp, di, change, change > 0 ? fobjname : tobjname, &tsb); } else if (strcmp(fobjname, tobjname) == 0) { - print_file(fp, di, ZDIFF_MODIFIED, fobjname, &tsb); + print_file(fp, di, *ZDIFF_MODIFIED, fobjname, &tsb); } else { print_rename(fp, di, fobjname, tobjname, &tsb); }