s3: libsmb: Change generate_inode()/setup_stat() to modern coding standards.
authorJeremy Allison <jra@samba.org>
Fri, 18 Oct 2019 16:24:38 +0000 (09:24 -0700)
committerRalph Boehme <slow@samba.org>
Wed, 30 Oct 2019 20:44:31 +0000 (20:44 +0000)
Change setup_stat() to be void. It doesn't return anything. Export
so it can be used by upcoming smbc_readdirplus2() call.

Remove unused SMBCCTX *context parameters.
Remove unused talloc_stackframe().

Signed-off-by: Puran Chand <pchand@vmware.com>
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/include/libsmb_internal.h
source3/libsmb/libsmb_stat.c

index f3e44e875d88bc0d9320bd10a9fb6b6fa2459046..16a5673e4d2caa2c0fe9fce8ff2e9814e0abe3a5 100644 (file)
@@ -522,6 +522,11 @@ SMBC_attr_server(TALLOC_CTX *ctx,
 
 
 /* Functions in libsmb_stat.c */
+void setup_stat(struct stat *st,
+               const char *fname,
+               off_t size,
+               int mode);
+
 int
 SMBC_stat_ctx(SMBCCTX *context,
               const char *fname,
index 2f6e66c08e5d307c2e166bd4c7b84efc34961760..fb9dd63e7a6e826e639f4a6b1f98cd1fcfc0acfa 100644 (file)
  * Generate an inode number from file name for those things that need it
  */
 
-static ino_t
-generate_inode(SMBCCTX *context,
-               const char *name)
+static ino_t generate_inode(const char *name)
 {
-       if (!context || !context->internal->initialized) {
-               errno = EINVAL;
-               return -1;
+       if (name == NULL) {
+               return (ino_t)-1;
        }
-
-       if (!*name) return 2; /* FIXME, why 2 ??? */
        return (ino_t)str_checksum(name);
 }
 
@@ -50,15 +45,11 @@ generate_inode(SMBCCTX *context,
  * fstat below.
  */
 
-static int
-setup_stat(SMBCCTX *context,
-           struct stat *st,
-           const char *fname,
-           off_t size,
-           int mode)
+void setup_stat(struct stat *st,
+               const char *fname,
+               off_t size,
+               int mode)
 {
-       TALLOC_CTX *frame = talloc_stackframe();
-
        st->st_mode = 0;
 
        if (IS_DOS_DIR(mode)) {
@@ -67,10 +58,18 @@ setup_stat(SMBCCTX *context,
                st->st_mode = SMBC_FILE_MODE;
        }
 
-       if (IS_DOS_ARCHIVE(mode)) st->st_mode |= S_IXUSR;
-       if (IS_DOS_SYSTEM(mode)) st->st_mode |= S_IXGRP;
-       if (IS_DOS_HIDDEN(mode)) st->st_mode |= S_IXOTH;
-       if (!IS_DOS_READONLY(mode)) st->st_mode |= S_IWUSR;
+       if (IS_DOS_ARCHIVE(mode)) {
+               st->st_mode |= S_IXUSR;
+       }
+       if (IS_DOS_SYSTEM(mode)) {
+               st->st_mode |= S_IXGRP;
+       }
+       if (IS_DOS_HIDDEN(mode)) {
+               st->st_mode |= S_IXOTH;
+       }
+       if (!IS_DOS_READONLY(mode)) {
+               st->st_mode |= S_IWUSR;
+       }
 
        st->st_size = size;
 #ifdef HAVE_STAT_ST_BLKSIZE
@@ -92,11 +91,8 @@ setup_stat(SMBCCTX *context,
        }
 
        if (st->st_ino == 0) {
-               st->st_ino = generate_inode(context, fname);
+               st->st_ino = generate_inode(fname);
        }
-
-       TALLOC_FREE(frame);
-       return True;  /* FIXME: Is this needed ? */
 }
 
 /*
@@ -183,7 +179,7 @@ SMBC_stat_ctx(SMBCCTX *context,
 
        st->st_ino = ino;
 
-       setup_stat(context, st, fname, size, mode);
+       setup_stat(st, fname, size, mode);
 
        st->st_atime = convert_timespec_to_time_t(access_time_ts);
        st->st_ctime = convert_timespec_to_time_t(change_time_ts);
@@ -288,7 +284,7 @@ SMBC_fstat_ctx(SMBCCTX *context,
 
        st->st_ino = ino;
 
-       setup_stat(context, st, file->fname, size, mode);
+       setup_stat(st, file->fname, size, mode);
 
        st->st_atime = convert_timespec_to_time_t(access_time_ts);
        st->st_ctime = convert_timespec_to_time_t(change_time_ts);