[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Wed Oct 3 02:12:03 UTC 2018
The branch, master has been updated
via 43a0e63 leases: Streamline leases_db_key a bit
via e22d5e5 smbd: Fix a warning
via 826a212 lib: Remove unused tdb_pack_append()
via 4060e26 includes: Remove an unused #define
via f8fab07 includes: Fix a typo
via 965d7e9 includes: Remove an unused #define
via 1853fd4 third_party: Update cmocka to version 1.1.3
from cff1b31 smbd: Simplify downgrade_share_lease
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 43a0e635ea6b7b1d246664248641a4b96955a4d4
Author: Volker Lendecke <vl at samba.org>
Date: Thu Sep 13 21:05:05 2018 +0200
leases: Streamline leases_db_key a bit
We don't need to talloc the blob, it's always the same size
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Wed Oct 3 04:11:59 CEST 2018 on sn-devel-144
commit e22d5e5b7fd6af75a7b46c0b9fed7e65025930a2
Author: Volker Lendecke <vl at samba.org>
Date: Mon Sep 10 14:59:14 2018 +0200
smbd: Fix a warning
gcc complains that the "const" is ignored on function return
types. Right now I'm compiling this file a lot, so silence this
warning :-)
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 826a212771e521eadc0229ed8631a7f9a7f96215
Author: Volker Lendecke <vl at samba.org>
Date: Tue Sep 25 08:57:17 2018 -0700
lib: Remove unused tdb_pack_append()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 4060e2637b8bac99aba01bb2d337d493a6cc06d0
Author: Volker Lendecke <vl at samba.org>
Date: Tue Sep 25 04:02:35 2018 -0700
includes: Remove an unused #define
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit f8fab07c89e3b61bcf225a1438e8134420b8b9be
Author: Volker Lendecke <vl at samba.org>
Date: Tue Sep 25 03:58:29 2018 -0700
includes: Fix a typo
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 965d7e905f9bca0779de09d2788ac0cb5dfc6e2b
Author: Volker Lendecke <vl at samba.org>
Date: Tue Sep 25 03:58:16 2018 -0700
includes: Remove an unused #define
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 1853fd4f9750d5b1997471baf1ef74fa88931da3
Author: Andreas Schneider <asn at samba.org>
Date: Tue Sep 4 17:50:15 2018 +0200
third_party: Update cmocka to version 1.1.3
* Added function to filter tests (cmocka_set_test_filter)
* Fixed fixture error reporting
* Some improvement for API documentation -> https://api.cmocka.org/
* Fixed subunit output on failures
* Do not abort if a test is skipped
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
buildtools/wafsamba/samba_third_party.py | 2 +-
source3/include/smb.h | 11 +-
source3/include/util_tdb.h | 2 -
source3/lib/util_tdb.c | 34 ----
source3/locking/leases_db.c | 62 +++-----
source3/locking/share_mode_lock.c | 2 +-
third_party/cmocka/cmocka.c | 261 +++++++++++++++++++++++--------
third_party/cmocka/cmocka.h | 28 +++-
8 files changed, 238 insertions(+), 164 deletions(-)
Changeset truncated at 500 lines:
diff --git a/buildtools/wafsamba/samba_third_party.py b/buildtools/wafsamba/samba_third_party.py
index f869af5..dbecf71 100644
--- a/buildtools/wafsamba/samba_third_party.py
+++ b/buildtools/wafsamba/samba_third_party.py
@@ -36,7 +36,7 @@ Build.BuildContext.CHECK_POPT = CHECK_POPT
@conf
def CHECK_CMOCKA(conf):
- return conf.CHECK_BUNDLED_SYSTEM_PKG('cmocka', minversion='1.1.1')
+ return conf.CHECK_BUNDLED_SYSTEM_PKG('cmocka', minversion='1.1.3')
Build.BuildContext.CHECK_CMOCKA = CHECK_CMOCKA
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 89469fc..0fd9471 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -50,10 +50,6 @@
#define SIZEOFWORD 2
-#ifndef DEF_CREATE_MASK
-#define DEF_CREATE_MASK (0755)
-#endif
-
/* string manipulation flags - see clistr.c and srvstr.c */
#define STR_TERMINATE 1
#define STR_UPPER 2
@@ -546,13 +542,8 @@ enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT,
#define FNUM_FIELD_INVALID 0
-/*
- * Size of buffer to use when moving files across filesystems.
- */
-#define COPYBUF_SIZE (8*1024)
-
/*
- * Map the Core and Extended Oplock requesst bits down
+ * Map the Core and Extended Oplock request bits down
* to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK).
*/
diff --git a/source3/include/util_tdb.h b/source3/include/util_tdb.h
index 1116033..8dc1048 100644
--- a/source3/include/util_tdb.h
+++ b/source3/include/util_tdb.h
@@ -38,8 +38,6 @@ int tdb_trans_delete(struct tdb_context *tdb, TDB_DATA key);
*/
int tdb_unpack(const uint8_t *buf, int bufsize, const char *fmt, ...);
size_t tdb_pack(uint8_t *buf, int bufsize, const char *fmt, ...);
-bool tdb_pack_append(TALLOC_CTX *mem_ctx, uint8_t **buf, size_t *len,
- const char *fmt, ...);
struct tdb_context *tdb_open_log(const char *name, int hash_size,
int tdb_flags, int open_flags, mode_t mode);
diff --git a/source3/lib/util_tdb.c b/source3/lib/util_tdb.c
index 1e533e8..80e66e0 100644
--- a/source3/lib/util_tdb.c
+++ b/source3/lib/util_tdb.c
@@ -140,40 +140,6 @@ size_t tdb_pack(uint8_t *buf, int bufsize, const char *fmt, ...)
return result;
}
-bool tdb_pack_append(TALLOC_CTX *mem_ctx, uint8_t **buf, size_t *len,
- const char *fmt, ...)
-{
- va_list ap;
- size_t len1, len2;
-
- va_start(ap, fmt);
- len1 = tdb_pack_va(NULL, 0, fmt, ap);
- va_end(ap);
-
- if (mem_ctx != NULL) {
- *buf = talloc_realloc(mem_ctx, *buf, uint8_t,
- (*len) + len1);
- } else {
- *buf = SMB_REALLOC_ARRAY(*buf, uint8_t, (*len) + len1);
- }
-
- if (*buf == NULL) {
- return False;
- }
-
- va_start(ap, fmt);
- len2 = tdb_pack_va((*buf)+(*len), len1, fmt, ap);
- va_end(ap);
-
- if (len1 != len2) {
- return False;
- }
-
- *len += len2;
-
- return True;
-}
-
/****************************************************************************
Useful pair of routines for packing/unpacking data consisting of
integers and strings.
diff --git a/source3/locking/leases_db.c b/source3/locking/leases_db.c
index ea63b00..3157628 100644
--- a/source3/locking/leases_db.c
+++ b/source3/locking/leases_db.c
@@ -60,33 +60,30 @@ bool leases_db_init(bool read_only)
return true;
}
-static bool leases_db_key(TALLOC_CTX *mem_ctx,
- const struct GUID *client_guid,
- const struct smb2_lease_key *lease_key,
- TDB_DATA *key)
+struct leases_db_key_buf {
+ uint8_t buf[32];
+};
+
+static TDB_DATA leases_db_key(struct leases_db_key_buf *buf,
+ const struct GUID *client_guid,
+ const struct smb2_lease_key *lease_key)
{
struct leases_db_key db_key = {
.client_guid = *client_guid,
.lease_key = *lease_key };
- DATA_BLOB blob;
+ DATA_BLOB blob = { .data = buf->buf, .length = sizeof(buf->buf) };
enum ndr_err_code ndr_err;
if (DEBUGLEVEL >= 10) {
- DEBUG(10, ("%s:\n", __func__));
+ DBG_DEBUG("\n");
NDR_PRINT_DEBUG(leases_db_key, &db_key);
}
- ndr_err = ndr_push_struct_blob(
- &blob, mem_ctx, &db_key,
- (ndr_push_flags_fn_t)ndr_push_leases_db_key);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- DEBUG(10, ("%s: ndr_push_struct_blob_failed: %s\n",
- __func__, ndr_errstr(ndr_err)));
- return false;
- }
+ ndr_err = ndr_push_struct_into_fixed_blob(
+ &blob, &db_key, (ndr_push_flags_fn_t)ndr_push_leases_db_key);
+ SMB_ASSERT(NDR_ERR_CODE_IS_SUCCESS(ndr_err));
- *key = make_tdb_data(blob.data, blob.length);
- return true;
+ return (TDB_DATA) { .dptr = buf->buf, .dsize = sizeof(buf->buf) };
}
NTSTATUS leases_db_add(const struct GUID *client_guid,
@@ -96,11 +93,12 @@ NTSTATUS leases_db_add(const struct GUID *client_guid,
const char *base_name,
const char *stream_name)
{
- TDB_DATA db_key, db_value;
+ struct leases_db_key_buf keybuf;
+ TDB_DATA db_key = leases_db_key(&keybuf, client_guid, lease_key);
+ TDB_DATA db_value;
DATA_BLOB blob;
struct db_record *rec;
NTSTATUS status;
- bool ok;
struct leases_db_value new_value;
struct leases_db_file new_file;
struct leases_db_value *value = NULL;
@@ -110,14 +108,7 @@ NTSTATUS leases_db_add(const struct GUID *client_guid,
return NT_STATUS_INTERNAL_ERROR;
}
- ok = leases_db_key(talloc_tos(), client_guid, lease_key, &db_key);
- if (!ok) {
- DEBUG(10, ("%s: leases_db_key failed\n", __func__));
- return NT_STATUS_NO_MEMORY;
- }
-
rec = dbwrap_fetch_locked(leases_db, talloc_tos(), db_key);
- TALLOC_FREE(db_key.dptr);
if (rec == NULL) {
return NT_STATUS_INTERNAL_ERROR;
}
@@ -221,26 +212,21 @@ NTSTATUS leases_db_del(const struct GUID *client_guid,
const struct smb2_lease_key *lease_key,
const struct file_id *id)
{
- TDB_DATA db_key, db_value;
+ struct leases_db_key_buf keybuf;
+ TDB_DATA db_key = leases_db_key(&keybuf, client_guid, lease_key);
+ TDB_DATA db_value;
struct db_record *rec;
NTSTATUS status;
struct leases_db_value *value;
enum ndr_err_code ndr_err;
DATA_BLOB blob;
uint32_t i;
- bool ok;
if (!leases_db_init(false)) {
return NT_STATUS_INTERNAL_ERROR;
}
- ok = leases_db_key(talloc_tos(), client_guid, lease_key, &db_key);
- if (!ok) {
- return NT_STATUS_NO_MEMORY;
- }
-
rec = dbwrap_fetch_locked(leases_db, talloc_tos(), db_key);
- TALLOC_FREE(db_key.dptr);
if (rec == NULL) {
return NT_STATUS_NOT_FOUND;
}
@@ -372,20 +358,15 @@ NTSTATUS leases_db_parse(const struct GUID *client_guid,
void *private_data),
void *private_data)
{
- TDB_DATA db_key;
+ struct leases_db_key_buf keybuf;
+ TDB_DATA db_key = leases_db_key(&keybuf, client_guid, lease_key);
struct leases_db_fetch_state state;
NTSTATUS status;
- bool ok;
if (!leases_db_init(true)) {
return NT_STATUS_INTERNAL_ERROR;
}
- ok = leases_db_key(talloc_tos(), client_guid, lease_key, &db_key);
- if (!ok) {
- return NT_STATUS_NO_MEMORY;
- }
-
state = (struct leases_db_fetch_state) {
.parser = parser,
.private_data = private_data,
@@ -394,7 +375,6 @@ NTSTATUS leases_db_parse(const struct GUID *client_guid,
status = dbwrap_parse_record(leases_db, db_key, leases_db_parser,
&state);
- TALLOC_FREE(db_key.dptr);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c
index 919e74c..a97d8d4 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -142,7 +142,7 @@ static TDB_DATA locking_key(const struct file_id *id)
necessary we can always make this a separate (smaller) cache.
******************************************************************/
-static const DATA_BLOB memcache_key(const struct file_id *id)
+static DATA_BLOB memcache_key(const struct file_id *id)
{
return data_blob_const((const void *)id, sizeof(*id));
}
diff --git a/third_party/cmocka/cmocka.c b/third_party/cmocka/cmocka.c
index 0861c2c..b21fe15 100644
--- a/third_party/cmocka/cmocka.c
+++ b/third_party/cmocka/cmocka.c
@@ -1,6 +1,6 @@
/*
* Copyright 2008 Google Inc.
- * Copyright 2014-2015 Andreas Schneider <asn at cryptomilk.org>
+ * Copyright 2014-2018 Andreas Schneider <asn at cryptomilk.org>
* Copyright 2015 Jakub Hrozek <jakub.hrozek at posteo.se>
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -45,7 +45,7 @@
#include <time.h>
/*
- * This allows one to add a platform specific header file. Some embedded platforms
+ * This allows to add a platform specific header file. Some embedded platforms
* sometimes miss certain types and definitions.
*
* Example:
@@ -148,12 +148,17 @@ typedef struct ListNode {
} ListNode;
/* Debug information for malloc(). */
-typedef struct MallocBlockInfo {
+struct MallocBlockInfoData {
void* block; /* Address of the block returned by malloc(). */
size_t allocated_size; /* Total size of the allocated block. */
size_t size; /* Request block size. */
SourceLocation location; /* Where the block was allocated. */
ListNode node; /* Node within list of all allocated blocks. */
+};
+
+typedef union {
+ struct MallocBlockInfoData *data;
+ char *ptr;
} MallocBlockInfo;
/* State of each test. */
@@ -247,7 +252,7 @@ static void remove_always_return_values(ListNode * const map_head,
static size_t check_for_leftover_values_list(const ListNode * head,
const char * const error_message);
-static int check_for_leftover_values(
+static size_t check_for_leftover_values(
const ListNode * const map_head, const char * const error_message,
const size_t number_of_symbol_names);
@@ -305,6 +310,8 @@ static CMOCKA_THREAD ListNode global_allocated_blocks;
static enum cm_message_output global_msg_output = CM_OUTPUT_STDOUT;
+static const char *global_test_filter_pattern;
+
#ifndef _WIN32
/* Signals caught by exception_handler(). */
static const int exception_signals[] = {
@@ -381,9 +388,15 @@ struct CMUnitTestState {
/* Exit the currently executing test. */
static void exit_test(const int quit_application)
{
- const char *abort_test = getenv("CMOCKA_TEST_ABORT");
+ const char *env = getenv("CMOCKA_TEST_ABORT");
+ int abort_test = 0;
+
+ if (env != NULL && strlen(env) == 1) {
+ abort_test = (env[0] == '1');
+ }
- if (abort_test != NULL && abort_test[0] == '1') {
+ if (global_skip_test == 0 &&
+ abort_test == 1) {
print_error("%s", cm_error_message);
abort();
} else if (global_running_test) {
@@ -453,7 +466,7 @@ static int c_strreplace(char *src,
memmove(src + of + rl, src + of + pl, l - of - pl + 1);
}
- strncpy(src + of, repl, rl);
+ memcpy(src + of, repl, rl);
if (str_replaced != NULL) {
*str_replaced = 1;
@@ -464,6 +477,64 @@ static int c_strreplace(char *src,
return 0;
}
+static int c_strmatch(const char *str, const char *pattern)
+{
+ int ok;
+
+ if (str == NULL || pattern == NULL) {
+ return 0;
+ }
+
+ for (;;) {
+ /* Check if pattern is done */
+ if (*pattern == '\0') {
+ /* If string is at the end, we're good */
+ if (*str == '\0') {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ if (*pattern == '*') {
+ /* Move on */
+ pattern++;
+
+ /* If we are at the end, everything is fine */
+ if (*pattern == '\0') {
+ return 1;
+ }
+
+ /* Try to match each position */
+ for (; *str != '\0'; str++) {
+ ok = c_strmatch(str, pattern);
+ if (ok) {
+ return 1;
+ }
+ }
+
+ /* No match */
+ return 0;
+ }
+
+ /* If we are at the end, leave */
+ if (*str == '\0') {
+ return 0;
+ }
+
+ /* Check if we have a single wildcard or matching char */
+ if (*pattern != '?' && *str != *pattern) {
+ return 0;
+ }
+
+ /* Move string and pattern */
+ str++;
+ pattern++;
+ }
+
+ return 0;
+}
+
/* Create function results and expected parameter lists. */
void initialize_testing(const char *test_name) {
(void)test_name;
@@ -489,7 +560,8 @@ static void fail_if_leftover_values(const char *test_name) {
remove_always_return_values(&global_function_parameter_map_head, 2);
if (check_for_leftover_values(
&global_function_parameter_map_head,
- "%s parameter still has values that haven't been checked.\n", 2)) {
+ "'%s' parameter still has values that haven't been checked.\n",
+ 2)) {
error_occurred = 1;
}
@@ -620,7 +692,7 @@ static int list_find(ListNode * const head, const void *value,
/* Returns the first node of a list */
static int list_first(ListNode * const head, ListNode **output) {
- ListNode *target_node;
+ ListNode *target_node = NULL;
assert_non_null(head);
if (list_empty(head)) {
return 0;
@@ -708,8 +780,8 @@ static void add_symbol_value(ListNode * const symbol_map_head,
static int get_symbol_value(
ListNode * const head, const char * const symbol_names[],
const size_t number_of_symbol_names, void **output) {
- const char* symbol_name;
- ListNode *target_node;
+ const char* symbol_name = NULL;
+ ListNode *target_node = NULL;
assert_non_null(head);
assert_non_null(symbol_names);
assert_true(number_of_symbol_names);
@@ -717,8 +789,8 @@ static int get_symbol_value(
symbol_name = symbol_names[0];
if (list_find(head, symbol_name, symbol_names_match, &target_node)) {
- SymbolMapValue *map_value;
- ListNode *child_list;
+ SymbolMapValue *map_value = NULL;
+ ListNode *child_list = NULL;
int return_value = 0;
assert_non_null(target_node);
assert_non_null(target_node->value);
@@ -730,6 +802,10 @@ static int get_symbol_value(
ListNode *value_node = NULL;
return_value = list_first(child_list, &value_node);
assert_true(return_value);
+ /* Add a check to silence clang analyzer */
+ if (return_value == 0) {
+ goto out;
+ }
*output = (void*) value_node->value;
return_value = value_node->refcount;
if (value_node->refcount - 1 == 0) {
@@ -746,9 +822,9 @@ static int get_symbol_value(
list_remove_free(target_node, free_symbol_map_value, (void*)0);
}
return return_value;
- } else {
- cm_print_error("No entries for symbol %s.\n", symbol_name);
}
+out:
+ cm_print_error("No entries for symbol %s.\n", symbol_name);
return 0;
}
@@ -835,11 +911,11 @@ static size_t check_for_leftover_values_list(const ListNode * head,
* Checks if there are any leftover values set up by the test that were never
* retrieved through execution, and fail the test if that is the case.
*/
-static int check_for_leftover_values(
+static size_t check_for_leftover_values(
const ListNode * const map_head, const char * const error_message,
const size_t number_of_symbol_names) {
const ListNode *current;
- int symbols_with_leftover_values = 0;
+ size_t symbols_with_leftover_values = 0;
assert_non_null(map_head);
assert_true(number_of_symbol_names);
@@ -865,7 +941,7 @@ static int check_for_leftover_values(
location->file, location->line);
}
} else {
- cm_print_error("%s.", value->symbol_name);
+ cm_print_error("%s: ", value->symbol_name);
check_for_leftover_values(child_list, error_message,
number_of_symbol_names - 1);
}
@@ -1187,19 +1263,24 @@ static int string_not_equal_display_error(
*/
static int memory_equal_display_error(const char* const a, const char* const b,
const size_t size) {
- int differences = 0;
+ size_t differences = 0;
size_t i;
--
Samba Shared Repository
More information about the samba-cvs
mailing list