]> arthur.barton.de Git - netatalk.git/blobdiff - bin/cnid/ad_cp.c
Remove unused var and check var dp in cleanup
[netatalk.git] / bin / cnid / ad_cp.c
index ae158361bcfbd6e4ea9963ce35d0e88d195e5342..25a112ab55b83cad398d7568c03d56eb414f6e7f 100644 (file)
@@ -1,6 +1,4 @@
 /* 
-   $Id: ad_cp.c,v 1.2 2009-10-13 22:55:36 didg Exp $
-
    Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
    
    This program is free software; you can redistribute it and/or modify
@@ -90,11 +88,11 @@ static int ad_cp_copy(const afpvol_t *srcvol, const afpvol_t *dstvol,
 
 static int ad_cp_r(const afpvol_t *srcvol, const afpvol_t *dstvol, char *srcdir, char *dstdir)
 {
-    int ret = 0, cwd, dirprinted = 0, dirempty;
+    int ret = 0, dirprinted = 0, dirempty;
     static char srcpath[MAXPATHLEN+1];
     static char dstpath[MAXPATHLEN+1];
-    char *tmp;
-    DIR *dp;
+    char *tmp1;
+    DIR *dp = NULL
     struct dirent *ep;
     static struct stat st;      /* Save some stack space */
 
@@ -165,10 +163,9 @@ static int ad_cp_r(const afpvol_t *srcvol, const afpvol_t *dstvol, char *srcdir,
     }
 
 exit:
-    closedir(dp);
-    fchdir(cwd);
-    close(cwd);
-
+    if (dp)
+        closedir(dp);
     if ((tmp = strrchr(srcpath, '/')))
         *tmp = 0;
     if ((tmp = strrchr(dstpath, '/')))