typedef the new history and recurse structs as per style guide
-emg
From 192bd627e01de5f66a1cd76ad733b55f21bfde52 Mon Sep 17 00:00:00 2001
From: Evan Gates <evan.ga...@gmail.com>
Date: Fri, 13 Mar 2015 10:55:23 -0700
Subject: [PATCH] typedef History and Recursor as per style guide

---
 chgrp.c           |  4 ++--
 chmod.c           |  4 ++--
 chown.c           |  4 ++--
 du.c              |  4 ++--
 fs.h              | 16 +++++++++-------
 libutil/recurse.c |  6 +++---
 libutil/rm.c      |  2 +-
 mv.c              |  2 +-
 rm.c              |  2 +-
 tar.c             |  4 ++--
 10 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/chgrp.c b/chgrp.c
index 2adf60d..9b743f6 100644
--- a/chgrp.c
+++ b/chgrp.c
@@ -15,7 +15,7 @@ static gid_t gid = -1;
 static int   ret = 0;
 
 static void
-chgrp(const char *path, void *data, struct recursor *r)
+chgrp(const char *path, void *data, Recursor *r)
 {
        char *chownf_name;
        int (*chownf)(const char *, uid_t, gid_t);
@@ -46,7 +46,7 @@ int
 main(int argc, char *argv[])
 {
        struct group *gr;
-       struct recursor r = { .fn = chgrp, .hist = NULL, .depth = 0, .follow = 
'P', .flags = 0 };
+       Recursor r = { .fn = chgrp, .hist = NULL, .depth = 0, .follow = 'P', 
.flags = 0 };
 
        ARGBEGIN {
        case 'h':
diff --git a/chmod.c b/chmod.c
index f93fc16..7a81561 100644
--- a/chmod.c
+++ b/chmod.c
@@ -10,7 +10,7 @@ static mode_t mask    = 0;
 static int    ret     = 0;
 
 static void
-chmodr(const char *path, void *data, struct recursor *r)
+chmodr(const char *path, void *data, Recursor *r)
 {
        struct stat st;
        mode_t m;
@@ -38,7 +38,7 @@ usage(void)
 int
 main(int argc, char *argv[])
 {
-       struct recursor r = { .fn = chmodr, .hist = NULL, .depth = 0, .follow = 
'P', .flags = 0};
+       Recursor r = { .fn = chmodr, .hist = NULL, .depth = 0, .follow = 'P', 
.flags = 0};
        size_t i;
 
        argv0 = *(argv++);
diff --git a/chown.c b/chown.c
index 290ac11..dc88fdf 100644
--- a/chown.c
+++ b/chown.c
@@ -17,7 +17,7 @@ static gid_t gid = -1;
 static int   ret = 0;
 
 static void
-chownpwgr(const char *path, void *data, struct recursor *r)
+chownpwgr(const char *path, void *data, Recursor *r)
 {
        char *chownf_name;
        int (*chownf)(const char *, uid_t, gid_t);
@@ -49,7 +49,7 @@ main(int argc, char *argv[])
 {
        struct group *gr;
        struct passwd *pw;
-       struct recursor r = { .fn = chownpwgr, .hist = NULL, .depth = 0, 
.follow = 'P', .flags = 0};
+       Recursor r = { .fn = chownpwgr, .hist = NULL, .depth = 0, .follow = 
'P', .flags = 0};
        char *owner, *group;
 
 
diff --git a/du.c b/du.c
index 6ecebc9..e7c91b5 100644
--- a/du.c
+++ b/du.c
@@ -35,7 +35,7 @@ nblks(blkcnt_t blocks)
 }
 
 void
-du(const char *path, void *total, struct recursor *r)
+du(const char *path, void *total, Recursor *r)
 {
        struct stat st;
        size_t subtotal = 0;
@@ -65,7 +65,7 @@ usage(void)
 int
 main(int argc, char *argv[])
 {
-       struct recursor r = { .fn = du, .hist = NULL, .depth = 0, .follow = 
'P', .flags = 0};
+       Recursor r = { .fn = du, .hist = NULL, .depth = 0, .follow = 'P', 
.flags = 0};
        size_t n = 0;
        int kflag = 0, dflag = 0;
        char *bsize;
diff --git a/fs.h b/fs.h
index 853996d..16c706d 100644
--- a/fs.h
+++ b/fs.h
@@ -1,15 +1,17 @@
 /* See LICENSE file for copyright and license details. */
 #include <sys/types.h>
 
-struct history {
-        struct history *prev;
+typedef struct History History;
+struct History {
+        History *prev;
         dev_t dev;
         ino_t ino;
 };
 
-struct recursor {
-        void (*fn)(const char *, void *, struct recursor *);
-        struct history *hist;
+typedef struct Recursor Recursor;
+struct Recursor {
+        void (*fn)(const char *, void *, Recursor *);
+        History *hist;
         int depth;
         int follow;
         int flags;
@@ -33,7 +35,7 @@ extern int rm_status;
 
 extern int recurse_status;
 
-void recurse(const char *, void *, struct recursor *);
+void recurse(const char *, void *, Recursor *);
 
 int cp(const char *, const char *, int);
-void rm(const char *, void *, struct recursor *);
+void rm(const char *, void *, Recursor *);
diff --git a/libutil/recurse.c b/libutil/recurse.c
index 1637d0c..1009b85 100644
--- a/libutil/recurse.c
+++ b/libutil/recurse.c
@@ -15,10 +15,10 @@
 int recurse_status = 0;
 
 void
-recurse(const char *path, void *data, struct recursor *r)
+recurse(const char *path, void *data, Recursor *r)
 {
        struct dirent *d;
-       struct history *new, *h;
+       History *new, *h;
        struct stat st, dst;
        DIR *dp;
        int (*statf)(const char *, struct stat *);
@@ -42,7 +42,7 @@ recurse(const char *path, void *data, struct recursor *r)
        if (!S_ISDIR(st.st_mode))
                return;
 
-       new = emalloc(sizeof(struct history));
+       new = emalloc(sizeof(History));
 
        new->prev  = r->hist;
        r->hist    = new;
diff --git a/libutil/rm.c b/libutil/rm.c
index 01b3763..052671f 100644
--- a/libutil/rm.c
+++ b/libutil/rm.c
@@ -10,7 +10,7 @@ int rm_rflag = 0;
 int rm_status = 0;
 
 void
-rm(const char *path, void *data, struct recursor *r)
+rm(const char *path, void *data, Recursor *r)
 {
        if (rm_rflag)
                recurse(path, NULL, r);
diff --git a/mv.c b/mv.c
index 148b4bc..b5981d6 100644
--- a/mv.c
+++ b/mv.c
@@ -12,7 +12,7 @@ static int mv_status = 0;
 static int
 mv(const char *s1, const char *s2, int depth)
 {
-       struct recursor r = { .fn = rm, .hist = NULL, .depth = 0, .follow = 
'P', .flags = 0};
+       Recursor r = { .fn = rm, .hist = NULL, .depth = 0, .follow = 'P', 
.flags = 0};
 
        if (!rename(s1, s2))
                return (mv_status = 0);
diff --git a/rm.c b/rm.c
index 17d75ed..86cb84f 100644
--- a/rm.c
+++ b/rm.c
@@ -11,7 +11,7 @@ usage(void)
 int
 main(int argc, char *argv[])
 {
-       struct recursor r = { .fn = rm, .hist = NULL, .depth = 0, .follow = 
'P', .flags = 0};
+       Recursor r = { .fn = rm, .hist = NULL, .depth = 0, .follow = 'P', 
.flags = 0};
 
        ARGBEGIN {
        case 'f':
diff --git a/tar.c b/tar.c
index b966b15..9aaec3b 100644
--- a/tar.c
+++ b/tar.c
@@ -235,7 +235,7 @@ print(char * fname, int l, char b[BLKSIZ])
 }
 
 static void
-c(const char *path, void *data, struct recursor *r)
+c(const char *path, void *data, Recursor *r)
 {
        archive(path);
        recurse(path, NULL, r);
@@ -267,7 +267,7 @@ int
 main(int argc, char *argv[])
 {
        FILE *fp;
-       struct recursor r = { .fn = c, .hist = NULL, .depth = 0, .follow = 'P', 
.flags = 0};
+       Recursor r = { .fn = c, .hist = NULL, .depth = 0, .follow = 'P', .flags 
= 0};
        struct stat st;
        char *file = NULL, *dir = ".", mode = '\0';
 
-- 
2.3.2

Reply via email to