The branch, master has been updated via da766db4e8a libsmb: Apply some const to parse_finfo_id_both_directory_info() via 4487ba9c2f1 libsmb: Remove unused cli_errstr() via f34dd442e78 torture3: Remove some ancient unused code via 3cc45aae6a5 libsmb: Move a variable declaration closer to its use via 52d4825a4ed libsmb: Remove some lines that were never used via c52a05d76fd libsmb: Avoid casts via abf9d1d7458 libsmb: Use IS[DOT]DOT via abff0c5e412 libsmb: Remove a pointless ZERO_STRUCT() via 4734b64e3f9 libsmb: Simplify callers of SMBC_dlist_contains() via 20b99b03a07 libsmb: Make SMBC_dlist_contains return bool via 66caa6b24d6 libsmb: Align calls to SMBC_dlist_contains() from 7ae03a19b3c build: add configure option to control vfs_snapper build
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit da766db4e8ae3b48719bbb75e12bdf3c9f25b484 Author: Volker Lendecke <v...@samba.org> Date: Sat May 16 17:33:38 2020 +0200 libsmb: Apply some const to parse_finfo_id_both_directory_info() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> Autobuild-User(master): Andreas Schneider <a...@cryptomilk.org> Autobuild-Date(master): Mon May 25 09:36:15 UTC 2020 on sn-devel-184 commit 4487ba9c2f158de347a6b370f4089783b2515c50 Author: Volker Lendecke <v...@samba.org> Date: Sat May 16 17:01:04 2020 +0200 libsmb: Remove unused cli_errstr() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit f34dd442e78316d29b1ba6647d69b3d4c38f9902 Author: Volker Lendecke <v...@samba.org> Date: Sat May 16 17:00:35 2020 +0200 torture3: Remove some ancient unused code Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit 3cc45aae6a523412fd4e0c1af6175c6b524e24e5 Author: Volker Lendecke <v...@samba.org> Date: Mon Apr 20 09:57:31 2020 +0200 libsmb: Move a variable declaration closer to its use Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit 52d4825a4ed87639f0954e8505508d6fac7a07ae Author: Volker Lendecke <v...@samba.org> Date: Sun Apr 19 14:40:56 2020 +0200 libsmb: Remove some lines that were never used Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit c52a05d76fd519a41711f672b2d7721b0dd0e4d1 Author: Volker Lendecke <v...@samba.org> Date: Sat Feb 22 11:52:51 2020 +0100 libsmb: Avoid casts Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit abf9d1d7458d275f1afaefd1903bf020bed16e63 Author: Volker Lendecke <v...@samba.org> Date: Sat Feb 22 11:48:45 2020 +0100 libsmb: Use IS[DOT]DOT strequal is not necessary here Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit abff0c5e412817ef3c0dddab7ddfda81cf1758f0 Author: Volker Lendecke <v...@samba.org> Date: Sat Feb 22 11:21:44 2020 +0100 libsmb: Remove a pointless ZERO_STRUCT() "c" is a pointer that was initialized to NULL above Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit 4734b64e3f9797894b7e8a2ce8119a099166a72c Author: Volker Lendecke <v...@samba.org> Date: Fri Feb 21 22:35:44 2020 +0100 libsmb: Simplify callers of SMBC_dlist_contains() This function already does the NULL check on the file pointer Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit 20b99b03a0795b920ac2be9d7e51bc6819f3d24f Author: Volker Lendecke <v...@samba.org> Date: Fri Feb 21 22:13:49 2020 +0100 libsmb: Make SMBC_dlist_contains return bool It returned True/False, and is used as boolean only. Modernize formatting a bit. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit 66caa6b24d69694ff030474b92b5c01687ab0a69 Author: Volker Lendecke <v...@samba.org> Date: Fri Feb 21 22:31:06 2020 +0100 libsmb: Align calls to SMBC_dlist_contains() Everywhere else it's called as !SMBC_dlist_contains() Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/include/libsmb_internal.h | 3 +-- source3/libsmb/cli_smb2_fnum.c | 2 +- source3/libsmb/clierror.c | 35 --------------------------- source3/libsmb/clifile.c | 34 -------------------------- source3/libsmb/libsmb_dir.c | 22 ++++++----------- source3/libsmb/libsmb_file.c | 24 ++++++++---------- source3/libsmb/libsmb_misc.c | 15 +++++++----- source3/libsmb/libsmb_server.c | 1 - source3/libsmb/libsmb_stat.c | 2 +- source3/libsmb/proto.h | 1 - source3/torture/torture.c | 51 --------------------------------------- 11 files changed, 30 insertions(+), 160 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h index be88e8e300d..13fd46977a0 100644 --- a/source3/include/libsmb_internal.h +++ b/source3/include/libsmb_internal.h @@ -430,8 +430,7 @@ SMBC_ftruncate_ctx(SMBCCTX *context, /* Functions in libsmb_misc.c */ -int -SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p); +bool SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p); int SMBC_errno(SMBCCTX *context, diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c index 0622a05a655..7fed546d63f 100644 --- a/source3/libsmb/cli_smb2_fnum.c +++ b/source3/libsmb/cli_smb2_fnum.c @@ -1202,7 +1202,7 @@ fail: Utility function to parse a SMB2_FIND_ID_BOTH_DIRECTORY_INFO reply. ***************************************************************/ -static NTSTATUS parse_finfo_id_both_directory_info(uint8_t *dir_data, +static NTSTATUS parse_finfo_id_both_directory_info(const uint8_t *dir_data, uint32_t dir_data_length, struct file_info *finfo, uint32_t *next_offset) diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 66dfea0654f..b92b3160174 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -23,41 +23,6 @@ #include "libsmb/libsmb.h" #include "../libcli/smb/smbXcli_base.h" -/*************************************************************************** - Return an error message - either an NT error, SMB error or a RAP error. - Note some of the NT errors are actually warnings or "informational" errors - in which case they can be safely ignored. -****************************************************************************/ - -const char *cli_errstr(struct cli_state *cli) -{ - fstring cli_error_message; - char *result; - - if (!cli->initialised) { - fstrcpy(cli_error_message, "[Programmer's error] cli_errstr called on uninitialized cli_stat struct!\n"); - goto done; - } - - /* Case #1: RAP error */ - if (cli->rap_error) { - strlcpy(cli_error_message, win_errstr(W_ERROR(cli->rap_error)), - sizeof(cli_error_message)); - goto done; - } - - if (!cli_state_is_connected(cli) && NT_STATUS_IS_OK(cli->raw_status)) { - return nt_errstr(NT_STATUS_CONNECTION_DISCONNECTED); - } - - return nt_errstr(cli->raw_status); - done: - result = talloc_strdup(talloc_tos(), cli_error_message); - SMB_ASSERT(result); - return result; -} - - /**************************************************************************** Return the 32-bit NT status code from the last packet. ****************************************************************************/ diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 28d85d1a9f8..cd7194585ae 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -3092,40 +3092,6 @@ NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags, dos_deny = 0xFF; } -#if 0 - /* Hmmm. This is what I think the above code - should look like if it's using the constants - we #define. JRA. */ - - if (flags & O_CREAT) { - openfn |= OPENX_FILE_CREATE_IF_NOT_EXIST; - } - if (!(flags & O_EXCL)) { - if (flags & O_TRUNC) - openfn |= OPENX_FILE_EXISTS_TRUNCATE; - else - openfn |= OPENX_FILE_EXISTS_OPEN; - } - - dos_deny = SET_DENY_MODE(share_mode_in); - - if ((flags & O_ACCMODE) == O_RDWR) { - dos_deny |= DOS_OPEN_RDWR; - } else if ((flags & O_ACCMODE) == O_WRONLY) { - dos_deny |= DOS_OPEN_WRONLY; - } - -#if defined(O_SYNC) - if ((flags & O_SYNC) == O_SYNC) { - dos_deny |= FILE_SYNC_OPENMODE; - } -#endif /* O_SYNC */ - - if (share_mode_in == DENY_FCB) { - dos_deny = 0xFF; - } -#endif - if (!map_open_params_to_ntcreate(fname, dos_deny, openfn, &access_mask, &share_mode, &create_disposition, diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c index 36caad88058..b95fee63795 100644 --- a/source3/libsmb/libsmb_dir.c +++ b/source3/libsmb/libsmb_dir.c @@ -467,7 +467,6 @@ SMBCFILE * SMBC_opendir_ctx(SMBCCTX *context, const char *fname) { - int saved_errno; char *server = NULL; char *share = NULL; char *user = NULL; @@ -961,6 +960,7 @@ SMBC_opendir_ctx(SMBCCTX *context, FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN, dir_list_fn, (void *)dir); if (!NT_STATUS_IS_OK(status)) { + int saved_errno; if (dir) { SAFE_FREE(dir->fname); SAFE_FREE(dir); @@ -1041,7 +1041,7 @@ SMBC_closedir_ctx(SMBCCTX *context, return -1; } - if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) { + if (!SMBC_dlist_contains(context->internal->files, dir)) { errno = EBADF; TALLOC_FREE(frame); return -1; @@ -1154,7 +1154,7 @@ SMBC_readdir_ctx(SMBCCTX *context, } - if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) { + if (!SMBC_dlist_contains(context->internal->files, dir)) { errno = EBADF; DEBUG(0, ("Invalid dir in SMBC_readdir_ctx()\n")); @@ -1233,9 +1233,7 @@ SMBC_readdirplus_ctx(SMBCCTX *context, return NULL; } - if (dir == NULL || - SMBC_dlist_contains(context->internal->files, - dir) == 0) { + if (!SMBC_dlist_contains(context->internal->files, dir)) { DBG_ERR("Invalid dir in SMBC_readdirplus_ctx()\n"); TALLOC_FREE(frame); errno = EBADF; @@ -1314,10 +1312,7 @@ const struct libsmb_file_info *SMBC_readdirplus2_ctx(SMBCCTX *context, return NULL; } - if (dir == NULL || - SMBC_dlist_contains(context->internal->files, - dir) == 0) - { + if (!SMBC_dlist_contains(context->internal->files, dir)) { DBG_ERR("Invalid dir in SMBC_readdirplus2_ctx()\n"); TALLOC_FREE(frame); errno = EBADF; @@ -1422,7 +1417,7 @@ SMBC_getdents_ctx(SMBCCTX *context, } - if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) { + if (!SMBC_dlist_contains(context->internal->files, dir)) { errno = EBADF; TALLOC_FREE(frame); @@ -1789,7 +1784,7 @@ SMBC_telldir_ctx(SMBCCTX *context, } - if (!dir || !SMBC_dlist_contains(context->internal->files, dir)) { + if (!SMBC_dlist_contains(context->internal->files, dir)) { errno = EBADF; TALLOC_FREE(frame); @@ -2633,8 +2628,7 @@ SMBC_notify_ctx(SMBCCTX *context, SMBCFILE *dir, smbc_bool recursive, errno = EINVAL; return -1; } - if ((dir == NULL) || - !SMBC_dlist_contains(context->internal->files, dir)) { + if (!SMBC_dlist_contains(context->internal->files, dir)) { TALLOC_FREE(frame); errno = EBADF; return -1; diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c index e4baa3b6adc..12da360158c 100644 --- a/source3/libsmb/libsmb_file.c +++ b/source3/libsmb/libsmb_file.c @@ -256,9 +256,9 @@ SMBC_read_ctx(SMBCCTX *context, return -1; } - DEBUG(4, ("smbc_read(%p, %d)\n", file, (int)count)); + DEBUG(4, ("smbc_read(%p, %zu)\n", file, count)); - if (!file || !SMBC_dlist_contains(context->internal->files, file)) { + if (!SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; @@ -284,7 +284,7 @@ SMBC_read_ctx(SMBCCTX *context, file->offset += ret; - DEBUG(4, (" --> %ld\n", (unsigned long)ret)); + DEBUG(4, (" --> %zu\n", ret)); TALLOC_FREE(frame); return ret; /* Success, ret bytes of data ... */ @@ -308,17 +308,13 @@ SMBC_splice_ctx(SMBCCTX *context, return -1; } - if (!srcfile || - !SMBC_dlist_contains(context->internal->files, srcfile)) - { + if (!SMBC_dlist_contains(context->internal->files, srcfile)) { errno = EBADF; TALLOC_FREE(frame); return -1; } - if (!dstfile || - !SMBC_dlist_contains(context->internal->files, dstfile)) - { + if (!SMBC_dlist_contains(context->internal->files, dstfile)) { errno = EBADF; TALLOC_FREE(frame); return -1; @@ -363,7 +359,7 @@ SMBC_write_ctx(SMBCCTX *context, return -1; } - if (!file || !SMBC_dlist_contains(context->internal->files, file)) { + if (!SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; @@ -409,7 +405,7 @@ SMBC_close_ctx(SMBCCTX *context, return -1; } - if (!file || !SMBC_dlist_contains(context->internal->files, file)) { + if (!SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; @@ -475,7 +471,7 @@ SMBC_getatr(SMBCCTX * context, } /* path fixup for . and .. */ - if (strequal(path, ".") || strequal(path, "..")) { + if (ISDOT(path) || ISDOTDOT(path)) { fixedpath = talloc_strdup(frame, "\\"); if (!fixedpath) { errno = ENOMEM; @@ -681,7 +677,7 @@ SMBC_lseek_ctx(SMBCCTX *context, return -1; } - if (!file || !SMBC_dlist_contains(context->internal->files, file)) { + if (!SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; @@ -744,7 +740,7 @@ SMBC_ftruncate_ctx(SMBCCTX *context, return -1; } - if (!file || !SMBC_dlist_contains(context->internal->files, file)) { + if (!SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; diff --git a/source3/libsmb/libsmb_misc.c b/source3/libsmb/libsmb_misc.c index 1d874c74cd8..28e2ca842cf 100644 --- a/source3/libsmb/libsmb_misc.c +++ b/source3/libsmb/libsmb_misc.c @@ -31,15 +31,18 @@ /* * check if an element is part of the list. */ -int -SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p) +bool SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p) { - if (!p || !list) return False; + if ((p == NULL) || (list == NULL)) { + return false; + } do { - if (p == list) return True; + if (p == list) { + return true; + } list = list->next; - } while (list); - return False; + } while (list != NULL); + return false; } diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c index 0067df48cac..41e0017fe59 100644 --- a/source3/libsmb/libsmb_server.c +++ b/source3/libsmb/libsmb_server.c @@ -296,7 +296,6 @@ SMBC_server_internal(TALLOC_CTX *ctx, bool use_ccache = false; bool pw_nt_hash = false; - ZERO_STRUCT(c); *in_cache = false; if (server[0] == 0) { diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c index 2372ec7454a..2b80415f002 100644 --- a/source3/libsmb/libsmb_stat.c +++ b/source3/libsmb/libsmb_stat.c @@ -251,7 +251,7 @@ SMBC_fstat_ctx(SMBCCTX *context, return -1; } - if (!file || !SMBC_dlist_contains(context->internal->files, file)) { + if (!SMBC_dlist_contains(context->internal->files, file)) { errno = EBADF; TALLOC_FREE(frame); return -1; diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h index b9764a4aae2..1ffc411c133 100644 --- a/source3/libsmb/proto.h +++ b/source3/libsmb/proto.h @@ -224,7 +224,6 @@ NTSTATUS cli_smb(TALLOC_CTX *mem_ctx, struct cli_state *cli, /* The following definitions come from libsmb/clierror.c */ -const char *cli_errstr(struct cli_state *cli); NTSTATUS cli_nt_error(struct cli_state *cli); void cli_dos_error(struct cli_state *cli, uint8_t *eclass, uint32_t *ecode); int cli_errno(struct cli_state *cli); diff --git a/source3/torture/torture.c b/source3/torture/torture.c index ab8e1937b03..6f652a7562d 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -1014,21 +1014,6 @@ static bool run_readwritelarge_internal(void) correct = False; } -#if 0 - /* ToDo - set allocation. JRA */ - if(!cli_set_allocation_size(cli1, fnum1, 0)) { - printf("set allocation size to zero failed (%s)\n", cli_errstr(&cli1)); - return False; - } - if (!cli_qfileinfo_basic(cli1, fnum1, NULL, &fsize, NULL, NULL, NULL, - NULL, NULL)) { - printf("qfileinfo failed (%s)\n", cli_errstr(cli1)); - correct = False; - } - if (fsize != 0) - printf("readwritelarge test 3 (truncate test) succeeded (size = %x)\n", fsize); -#endif - status = cli_close(cli1, fnum1); if (!NT_STATUS_IS_OK(status)) { printf("close failed (%s)\n", nt_errstr(status)); @@ -6341,27 +6326,6 @@ static bool run_rename(int dummy) } -#if 0 - { - uint16_t fnum2; - - if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, DELETE_ACCESS, FILE_ATTRIBUTE_NORMAL, - FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum2, NULL))) { - printf("Fourth open failed - %s\n", cli_errstr(cli1)); - return False; - } - if (!NT_STATUS_IS_OK(cli_nt_delete_on_close(cli1, fnum2, true))) { - printf("[8] setting delete_on_close on file failed !\n"); - return False; - } - - if (!NT_STATUS_IS_OK(cli_close(cli1, fnum2))) { - printf("close - 4 failed (%s)\n", cli_errstr(cli1)); - return False; - } - } -#endif - status = cli_rename(cli1, fname, fname1, false); if (!NT_STATUS_IS_OK(status)) { printf("Third rename failed (SHARE_NONE) - this should have succeeded - %s\n", nt_errstr(status)); @@ -6426,21 +6390,6 @@ static bool run_rename(int dummy) printf("Fifth rename succeeded (SHARE_READ | SHARE_WRITE | SHARE_DELETE) (this is correct) - %s\n", nt_errstr(status)); } - /* - * Now check if the first name still exists ... - */ - - /* if (!NT_STATUS_OP(cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - FILE_OVERWRITE_IF, 0, 0, &fnum2, NULL))) { - printf("Opening original file after rename of open file fails: %s\n", - cli_errstr(cli1)); - } - else { - printf("Opening original file after rename of open file works ...\n"); - (void)cli_close(cli1, fnum2); - } */ - /*--*/ status = cli_close(cli1, fnum1); if (!NT_STATUS_IS_OK(status)) { -- Samba Shared Repository