mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH] unlink_recursive: Drop struct data
Date: Thu, 17 Jan 2019 16:41:55 -0800	[thread overview]
Message-ID: <20190118004155.21725-1-andrew.smirnov@gmail.com> (raw)

Drop struct data which doesn't seem to serve any purpose in the code
and looks like a leftover.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 lib/unlink-recursive.c | 27 +++++++--------------------
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/lib/unlink-recursive.c b/lib/unlink-recursive.c
index 434fdc791..f28c6dae5 100644
--- a/lib/unlink-recursive.c
+++ b/lib/unlink-recursive.c
@@ -6,50 +6,37 @@
 
 static char unlink_recursive_failedpath[PATH_MAX];
 
-struct data {
-	int error;
-};
-
 static int file_action(const char *filename, struct stat *statbuf,
 			    void *userdata, int depth)
 {
-	struct data *data = userdata;
-	int ret;
-
-	ret = unlink(filename);
-	if (ret) {
+	if (unlink(filename)) {
 		strcpy(unlink_recursive_failedpath, filename);
-		data->error = ret;
+		return 0;
 	}
 
-	return ret ? 0 : 1;
+	return 1;
 }
 
 static int dir_action(const char *dirname, struct stat *statbuf,
 			    void *userdata, int depth)
 {
-	struct data *data = userdata;
-	int ret;
-
-	ret = rmdir(dirname);
-	if (ret) {
+	if (rmdir(dirname)) {
 		strcpy(unlink_recursive_failedpath, dirname);
-		data->error = ret;
+		return 0;
 	}
 
-	return ret ? 0 : 1;
+	return 1;
 }
 
 int unlink_recursive(const char *path, char **failedpath)
 {
-	struct data data = {};
 	int ret;
 
 	if (failedpath)
 		*failedpath = NULL;
 
 	ret = recursive_action(path, ACTION_RECURSE | ACTION_DEPTHFIRST,
-			file_action, dir_action, &data, 0);
+			file_action, dir_action, NULL, 0);
 
 	if (!ret && failedpath)
 		*failedpath = unlink_recursive_failedpath;
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2019-01-18  0:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-18  0:41 Andrey Smirnov [this message]
2019-01-24  7:25 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190118004155.21725-1-andrew.smirnov@gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox