* [PATCH] unlink_recursive: Drop struct data
@ 2019-01-18 0:41 Andrey Smirnov
2019-01-24 7:25 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Andrey Smirnov @ 2019-01-18 0:41 UTC (permalink / raw)
To: barebox; +Cc: Andrey Smirnov
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] unlink_recursive: Drop struct data
2019-01-18 0:41 [PATCH] unlink_recursive: Drop struct data Andrey Smirnov
@ 2019-01-24 7:25 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2019-01-24 7:25 UTC (permalink / raw)
To: Andrey Smirnov; +Cc: barebox
On Thu, Jan 17, 2019 at 04:41:55PM -0800, Andrey Smirnov wrote:
> 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(-)
Applied, thanks
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-24 7:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-18 0:41 [PATCH] unlink_recursive: Drop struct data Andrey Smirnov
2019-01-24 7:25 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox