From 88acd075a3a5bc34346b4916b848b67567aebc37 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Thu, 12 Jun 2014 22:24:42 +0200 Subject: [PATCH] Refactoring: move forkpath computation to function scope Preperation for new feature to delete zero byte sized resource forks. Signed-off-by: Ralph Boehme Change-Id: ef5f88f5f2cefa75cf20d0ee447b4e20579a2f12 --- etc/afpd/ofork.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/etc/afpd/ofork.c b/etc/afpd/ofork.c index ec60e066..8a04efb9 100644 --- a/etc/afpd/ofork.c +++ b/etc/afpd/ofork.c @@ -390,6 +390,7 @@ int of_closefork(const AFPObj *obj, struct ofork *ofork) int adflags = 0; int ret; struct dir *dir; + bstring forkpath = NULL; adflags = 0; if (ofork->of_flags & AFPFORK_DATA) @@ -411,13 +412,13 @@ int of_closefork(const AFPObj *obj, struct ofork *ofork) LOG(log_debug, logtype_afpd, "dirlookup failed for %ju", (uintmax_t)ofork->of_did); } + if (dir) { + forkpath = bformat("%s/%s", bdata(dir->d_fullpath), of_name(ofork)); + } + /* Somone has used write_fork, we assume file was changed, register it to file change event api */ - if (ofork->of_flags & AFPFORK_MODIFIED) { - if (dir) { - bstring forkpath = bformat("%s/%s", bdata(dir->d_fullpath), of_name(ofork)); - fce_register(FCE_FILE_MODIFY, bdata(forkpath), NULL, fce_file); - bdestroy(forkpath); - } + if ((ofork->of_flags & AFPFORK_MODIFIED) && (forkpath)) { + fce_register(FCE_FILE_MODIFY, bdata(forkpath), NULL, fce_file); } ad_unlock(ofork->of_ad, ofork->of_refnum, ofork->of_flags & AFPFORK_ERROR ? 0 : 1); @@ -440,6 +441,9 @@ int of_closefork(const AFPObj *obj, struct ofork *ofork) of_dealloc(ofork); + if (forkpath) + bdestroy(forkpath); + return ret; } -- 2.39.2