Fix warning about shadowed variables.

This commit is contained in:
Andreas Schneider 2008-04-16 10:30:05 +02:00
parent 269f5f5403
commit ec5d3afea0
2 changed files with 22 additions and 26 deletions

View file

@ -176,8 +176,7 @@ static int _closedir(csync_vio_method_t *dhandle) {
static csync_vio_file_stat_t *_readdir(csync_vio_method_handle_t *dhandle) { static csync_vio_file_stat_t *_readdir(csync_vio_method_handle_t *dhandle) {
struct smbc_dirent *dirent = NULL; struct smbc_dirent *dirent = NULL;
smb_dhandle_t *handle = NULL; smb_dhandle_t *handle = NULL;
csync_vio_file_stat_t *fstat = NULL; csync_vio_file_stat_t *file_stat = NULL;
struct stat sb;
handle = (smb_dhandle_t *) dhandle; handle = (smb_dhandle_t *) dhandle;
@ -186,18 +185,18 @@ static csync_vio_file_stat_t *_readdir(csync_vio_method_handle_t *dhandle) {
goto err; goto err;
} }
fstat = csync_vio_file_stat_new(); file_stat = csync_vio_file_stat_new();
if (fstat == NULL) { if (file_stat == NULL) {
goto err; goto err;
} }
fstat->name = c_strndup(dirent->name, dirent->namelen); file_stat->name = c_strndup(dirent->name, dirent->namelen);
fstat->fields = CSYNC_VIO_FILE_STAT_FIELDS_NONE; file_stat->fields = CSYNC_VIO_FILE_STAT_FIELDS_NONE;
switch (dirent->smbc_type) { switch (dirent->smbc_type) {
case SMBC_FILE_SHARE: case SMBC_FILE_SHARE:
fstat->fields |= CSYNC_VIO_FILE_STAT_FIELDS_TYPE; file_stat->fields |= CSYNC_VIO_FILE_STAT_FIELDS_TYPE;
fstat->type = CSYNC_VIO_FILE_TYPE_DIRECTORY; file_stat->type = CSYNC_VIO_FILE_TYPE_DIRECTORY;
break; break;
case SMBC_WORKGROUP: case SMBC_WORKGROUP:
case SMBC_SERVER: case SMBC_SERVER:
@ -206,15 +205,11 @@ static csync_vio_file_stat_t *_readdir(csync_vio_method_handle_t *dhandle) {
break; break;
case SMBC_DIR: case SMBC_DIR:
case SMBC_FILE: case SMBC_FILE:
if (smbc_stat(handle->path, &sb) < 0) { file_stat->fields |= CSYNC_VIO_FILE_STAT_FIELDS_TYPE;
goto err;
}
fstat->fields |= CSYNC_VIO_FILE_STAT_FIELDS_TYPE;
if (dirent->smbc_type == SMBC_DIR) { if (dirent->smbc_type == SMBC_DIR) {
fstat->type = CSYNC_VIO_FILE_TYPE_DIRECTORY; file_stat->type = CSYNC_VIO_FILE_TYPE_DIRECTORY;
} else { } else {
fstat->type = CSYNC_VIO_FILE_TYPE_REGULAR; file_stat->type = CSYNC_VIO_FILE_TYPE_REGULAR;
} }
break; break;
default: default:
@ -222,11 +217,11 @@ static csync_vio_file_stat_t *_readdir(csync_vio_method_handle_t *dhandle) {
} }
SAFE_FREE(dirent); SAFE_FREE(dirent);
return fstat; return file_stat;
err: err:
SAFE_FREE(dirent); SAFE_FREE(dirent);
SAFE_FREE(fstat); SAFE_FREE(file_stat);
return NULL; return NULL;
} }

View file

@ -24,22 +24,23 @@
#include "vio/csync_vio_file_stat_private.h" #include "vio/csync_vio_file_stat_private.h"
csync_vio_file_stat_t *csync_vio_file_stat_new(void) { csync_vio_file_stat_t *csync_vio_file_stat_new(void) {
csync_vio_file_stat_t *fstat = NULL; csync_vio_file_stat_t *file_stat = NULL;
fstat = (csync_vio_file_stat_t *) c_malloc(sizeof(csync_vio_file_stat_t)); file_stat = (csync_vio_file_stat_t *) c_malloc(sizeof(csync_vio_file_stat_t));
if (fstat == NULL) { if (file_stat == NULL) {
return NULL; return NULL;
} }
return fstat; return file_stat;
} }
void csync_vio_file_stat_destroy(csync_vio_file_stat_t *fstat) { void csync_vio_file_stat_destroy(csync_vio_file_stat_t *file_stat) {
/* FIXME: free rest */ /* FIXME: free rest */
if (fstat->fields == CSYNC_VIO_FILE_STAT_FIELDS_SYMLINK_NAME) { if (file_stat->fields == CSYNC_VIO_FILE_STAT_FIELDS_SYMLINK_NAME) {
SAFE_FREE(fstat->symlink_name); SAFE_FREE(file_stat->symlink_name);
} }
SAFE_FREE(fstat->name); SAFE_FREE(file_stat->name);
SAFE_FREE(fstat); SAFE_FREE(file_stat);
} }