27.02.2015 10:50, arei.gong...@huawei.com wrote: > From: Gonglei <arei.gong...@huawei.com> > > Signed-off-by: Gonglei <arei.gong...@huawei.com> > --- > hw/9pfs/virtio-9p-local.c | 10 ++-------- > 1 file changed, 2 insertions(+), 8 deletions(-) > > diff --git a/hw/9pfs/virtio-9p-local.c b/hw/9pfs/virtio-9p-local.c > index a183eee..bcad4e0 100644 > --- a/hw/9pfs/virtio-9p-local.c > +++ b/hw/9pfs/virtio-9p-local.c > @@ -500,7 +500,6 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath > *dir_path, > buffer = rpath(fs_ctx, path); > err = mknod(buffer, SM_LOCAL_MODE_BITS|S_IFREG, 0); > if (err == -1) { > - g_free(buffer); > goto out; > } > err = local_set_xattr(buffer, credp); > @@ -513,7 +512,6 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath > *dir_path, > buffer = rpath(fs_ctx, path); > err = mknod(buffer, SM_LOCAL_MODE_BITS|S_IFREG, 0); > if (err == -1) { > - g_free(buffer); > goto out; > } > err = local_set_mapped_file_attr(fs_ctx, path, credp); > @@ -526,7 +524,6 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath > *dir_path, > buffer = rpath(fs_ctx, path); > err = mknod(buffer, credp->fc_mode, credp->fc_rdev); > if (err == -1) { > - g_free(buffer); > goto out; > } ...
I wonder if we should change this code to drop repeated code blocks which changes only slightly by mknod parameters... > err = local_post_create_passthrough(fs_ctx, path, credp); > @@ -540,8 +537,8 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath > *dir_path, > err_end: > remove(buffer); > errno = serrno; > - g_free(buffer); > out: > + g_free(buffer); > v9fs_string_free(&fullname); > return err; > } ..and this goto jumping (here and in a few other places) is q bit disgusting too... ;) But this is the original code, the patch is still correct. Thanks, /mjt