vfs_gpfs: Use full_path_tos instead of talloc_asprintf
authorChristof Schmitt <cs@samba.org>
Tue, 22 May 2018 19:52:58 +0000 (12:52 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 25 May 2018 23:43:09 +0000 (01:43 +0200)
full_path_tos avoids the talloc call for most cases; use that instead of
talloc_asprintf.

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat May 26 01:43:09 CEST 2018 on sn-devel-144

source3/modules/vfs_gpfs.c

index 992785d91a36f9ea31c6cb70213bdc1d6f0cc1fa..d733df0aa5cf71289d4fd0b89e196b136bc8cf0d 100644 (file)
@@ -243,8 +243,10 @@ static int vfs_gpfs_get_real_filename(struct vfs_handle_struct *handle,
                                      char **found_name)
 {
        int result;
-       char *full_path;
-       char real_pathname[PATH_MAX+1];
+       char *full_path = NULL;
+       char *to_free = NULL;
+       char real_pathname[PATH_MAX+1], tmpbuf[PATH_MAX];
+       size_t full_path_len;
        int buflen;
        bool mangled;
        struct gpfs_config_data *config;
@@ -264,8 +266,9 @@ static int vfs_gpfs_get_real_filename(struct vfs_handle_struct *handle,
                                                      mem_ctx, found_name);
        }
 
-       full_path = talloc_asprintf(talloc_tos(), "%s/%s", path, name);
-       if (full_path == NULL) {
+       full_path_len = full_path_tos(path, name, tmpbuf, sizeof(tmpbuf),
+                                     &full_path, &to_free);
+       if (full_path_len == -1) {
                errno = ENOMEM;
                return -1;
        }
@@ -275,7 +278,7 @@ static int vfs_gpfs_get_real_filename(struct vfs_handle_struct *handle,
        result = gpfswrap_get_realfilename_path(full_path, real_pathname,
                                                &buflen);
 
-       TALLOC_FREE(full_path);
+       TALLOC_FREE(to_free);
 
        if ((result == -1) && (errno == ENOSYS)) {
                return SMB_VFS_NEXT_GET_REAL_FILENAME(