From 4183b2ac3832cdc2055d7eb3ed7121a9ea91085c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 2 Dec 2004 04:51:56 +0000 Subject: r4037: fixed a bunch of "might be uninitialised" warnings after enabling -O1 in my compile (This used to be commit 0928b1f5b68c858922c3ea6c27ed03b5091c6221) --- source4/auth/auth_util.c | 34 ++++++++++++---------- source4/client/client.c | 2 +- source4/ldap_server/ldap_simple_ldb.c | 10 +++---- source4/lib/dcom/common/main.c | 2 +- source4/lib/registry/common/reg_interface.c | 2 +- .../lib/registry/reg_backend_w95/reg_backend_w95.c | 2 +- source4/lib/registry/tools/regshell.c | 2 +- source4/libcli/auth/ntlmssp_sign.c | 2 ++ source4/libcli/raw/clisession.c | 2 +- source4/librpc/rpc/dcerpc_util.c | 2 +- source4/ntvfs/posix/pvfs_resolve.c | 4 +-- source4/rpc_server/dcom/remact.c | 4 +-- source4/torture/basic/denytest.c | 2 +- source4/torture/basic/locking.c | 2 +- source4/torture/dcom/simple.c | 2 +- source4/torture/raw/acls.c | 8 ++--- source4/torture/raw/eas.c | 2 +- source4/torture/raw/rename.c | 2 +- source4/torture/raw/streams.c | 2 +- source4/torture/rpc/samlogon.c | 6 ++-- source4/torture/rpc/xplogin.c | 2 +- source4/utils/net/net.c | 2 +- 22 files changed, 50 insertions(+), 48 deletions(-) diff --git a/source4/auth/auth_util.c b/source4/auth/auth_util.c index e929e59cc7..1ea7da4672 100644 --- a/source4/auth/auth_util.c +++ b/source4/auth/auth_util.c @@ -500,26 +500,28 @@ NTSTATUS make_server_info_netlogon_validation(TALLOC_CTX *mem_ctx, union netr_Validation *validation) { NTSTATUS nt_status; - struct netr_SamBaseInfo *base; + struct netr_SamBaseInfo *base = NULL; switch (validation_level) { - case 2: - if (!validation || !validation->sam2) { - return NT_STATUS_INVALID_PARAMETER; - } - base = &validation->sam2->base; + case 2: + if (!validation || !validation->sam2) { + return NT_STATUS_INVALID_PARAMETER; + } + base = &validation->sam2->base; break; - case 3: - if (!validation || !validation->sam3) { - return NT_STATUS_INVALID_PARAMETER; - } - base = &validation->sam3->base; + case 3: + if (!validation || !validation->sam3) { + return NT_STATUS_INVALID_PARAMETER; + } + base = &validation->sam3->base; break; - case 6: - if (!validation || !validation->sam6) { - return NT_STATUS_INVALID_PARAMETER; - } - base = &validation->sam6->base; + case 6: + if (!validation || !validation->sam6) { + return NT_STATUS_INVALID_PARAMETER; + } + base = &validation->sam6->base; break; + default: + return NT_STATUS_INVALID_LEVEL; } nt_status = make_server_info(mem_ctx, server_info, internal_username); diff --git a/source4/client/client.c b/source4/client/client.c index b438e986cd..d9e995f180 100644 --- a/source4/client/client.c +++ b/source4/client/client.c @@ -2671,7 +2671,7 @@ static char **completion_fn(const char *text, int start, int end) return NULL; } else { char **matches; - int i, len, samelen, count=1; + int i, len, samelen = 0, count=1; matches = (char **)malloc(sizeof(matches[0])*MAX_COMPLETIONS); if (!matches) return NULL; diff --git a/source4/ldap_server/ldap_simple_ldb.c b/source4/ldap_server/ldap_simple_ldb.c index 1b000f53ea..c33f04cafb 100644 --- a/source4/ldap_server/ldap_simple_ldb.c +++ b/source4/ldap_server/ldap_simple_ldb.c @@ -59,7 +59,7 @@ static NTSTATUS sldb_Search(struct ldapsrv_partition *partition, struct ldapsrv_ int result = LDAP_SUCCESS; struct samdb_context *samdb; struct ldb_message **res; - int i, j, y, count; + int i, j, y, count = 0; enum ldb_scope scope = LDB_SCOPE_DEFAULT; const char **attrs = NULL; const char *errstr = NULL; @@ -183,7 +183,7 @@ static NTSTATUS sldb_Add(struct ldapsrv_partition *partition, struct ldapsrv_cal struct ldapsrv_reply *add_reply; int ldb_ret; struct samdb_context *samdb; - struct ldb_message *msg; + struct ldb_message *msg = NULL; int result = LDAP_SUCCESS; const char *errstr = NULL; int i,j; @@ -336,7 +336,7 @@ static NTSTATUS sldb_Modify(struct ldapsrv_partition *partition, struct ldapsrv_ struct ldapsrv_reply *modify_reply; int ldb_ret; struct samdb_context *samdb; - struct ldb_message *msg; + struct ldb_message *msg = NULL; int result = LDAP_SUCCESS; const char *errstr = NULL; int i,j; @@ -450,7 +450,7 @@ static NTSTATUS sldb_Compare(struct ldapsrv_partition *partition, struct ldapsrv struct ldb_message **res; const char *attrs[1]; const char *errstr = NULL; - const char *filter; + const char *filter = NULL; int count; local_ctx = talloc_named(call, 0, "sldb_Compare local_memory_context"); @@ -517,7 +517,7 @@ NTSTATUS sldb_ModifyDN(struct ldapsrv_partition *partition, struct ldapsrv_call struct samdb_context *samdb; const char *errstr = NULL; int result = LDAP_SUCCESS; - const char *newdn; + const char *newdn = NULL; char *parentdn = NULL; local_ctx = talloc_named(call, 0, "sldb_ModifyDN local memory context"); diff --git a/source4/lib/dcom/common/main.c b/source4/lib/dcom/common/main.c index 61fd7d3ff7..09c5fd280c 100644 --- a/source4/lib/dcom/common/main.c +++ b/source4/lib/dcom/common/main.c @@ -209,7 +209,7 @@ static WERROR dcom_create_object_remote(struct dcom_context *ctx, struct GUID *c WERROR dcom_create_object(struct dcom_context *ctx, struct GUID *clsid, const char *server, int num_ifaces, struct GUID *iid, struct dcom_interface_p ***ip, WERROR *results) { - struct dcom_interface_p *factory, *iunk; + struct dcom_interface_p *factory, *iunk = NULL; struct QueryInterface qr; struct Release rr; struct CreateInstance cr; diff --git a/source4/lib/registry/common/reg_interface.c b/source4/lib/registry/common/reg_interface.c index 77440cea0f..dea8861745 100644 --- a/source4/lib/registry/common/reg_interface.c +++ b/source4/lib/registry/common/reg_interface.c @@ -614,7 +614,7 @@ WERROR reg_key_get_parent(TALLOC_CTX *mem_ctx, struct registry_key *key, struct { char *parent_name; char *last; - struct registry_key *root; + struct registry_key *root = NULL; WERROR error; parent_name = strdup(key->path); diff --git a/source4/lib/registry/reg_backend_w95/reg_backend_w95.c b/source4/lib/registry/reg_backend_w95/reg_backend_w95.c index fb73e9052c..445d13a99c 100644 --- a/source4/lib/registry/reg_backend_w95/reg_backend_w95.c +++ b/source4/lib/registry/reg_backend_w95/reg_backend_w95.c @@ -320,7 +320,7 @@ static WERROR w95_get_value_by_id(TALLOC_CTX *mem_ctx, struct registry_key *k, i DWORD i; DWORD offset = 0; RGDB_KEY *rgdb_key = LOCN_RGDB_KEY((CREG *)k->hive->backend_data, rgkn_key->id.rgdb, rgkn_key->id.id); - RGDB_VALUE *curval; + RGDB_VALUE *curval = NULL; if(!rgdb_key) return WERR_FOOBAR; diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c index 8d044f6fa2..3333299088 100644 --- a/source4/lib/registry/tools/regshell.c +++ b/source4/lib/registry/tools/regshell.c @@ -245,7 +245,7 @@ static char **reg_complete_command(const char *text, int end) { /* Complete command */ char **matches; - int i, len, samelen, count=1; + int i, len, samelen=0, count=1; matches = (char **)malloc(sizeof(matches[0])*MAX_COMPLETIONS); if (!matches) return NULL; diff --git a/source4/libcli/auth/ntlmssp_sign.c b/source4/libcli/auth/ntlmssp_sign.c index e2f5237a88..1b391306bc 100644 --- a/source4/libcli/auth/ntlmssp_sign.c +++ b/source4/libcli/auth/ntlmssp_sign.c @@ -368,6 +368,8 @@ NTSTATUS ntlmssp_sign_init(struct ntlmssp_state *ntlmssp_state) recv_sign_const = CLI_SIGN; recv_seal_const = CLI_SEAL; break; + default: + return NT_STATUS_INTERNAL_ERROR; } /** diff --git a/source4/libcli/raw/clisession.c b/source4/libcli/raw/clisession.c index b7802d8065..c92e3ecb0b 100644 --- a/source4/libcli/raw/clisession.c +++ b/source4/libcli/raw/clisession.c @@ -393,7 +393,7 @@ static NTSTATUS smb_raw_session_setup_generic_spnego(struct smbcli_session *sess union smb_sesssetup s2; DATA_BLOB session_key = data_blob(NULL, 0); DATA_BLOB null_data_blob = data_blob(NULL, 0); - const char *chosen_oid; + const char *chosen_oid = NULL; s2.generic.level = RAW_SESSSETUP_SPNEGO; s2.spnego.in.bufsize = session->transport->options.max_xmit; diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c index b77c365858..8c454ab64f 100644 --- a/source4/librpc/rpc/dcerpc_util.c +++ b/source4/librpc/rpc/dcerpc_util.c @@ -602,7 +602,7 @@ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, struct epm_tower *tower, NTSTATUS dcerpc_binding_build_tower(TALLOC_CTX *mem_ctx, struct dcerpc_binding *binding, struct epm_tower *tower) { - const enum epm_protocols *protseq; + const enum epm_protocols *protseq = NULL; int num_protocols = -1, i; NTSTATUS status; diff --git a/source4/ntvfs/posix/pvfs_resolve.c b/source4/ntvfs/posix/pvfs_resolve.c index 7329968d6c..7e7f49d0af 100644 --- a/source4/ntvfs/posix/pvfs_resolve.c +++ b/source4/ntvfs/posix/pvfs_resolve.c @@ -546,8 +546,8 @@ NTSTATUS pvfs_resolve_partial(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx, NTSTATUS pvfs_resolve_name_fd(struct pvfs_state *pvfs, int fd, struct pvfs_filename *name) { - dev_t device; - ino_t inode; + dev_t device = 0; + ino_t inode = 0; if (name->exists) { device = name->st.st_dev; diff --git a/source4/rpc_server/dcom/remact.c b/source4/rpc_server/dcom/remact.c index ee16d2ce10..30e508d65b 100644 --- a/source4/rpc_server/dcom/remact.c +++ b/source4/rpc_server/dcom/remact.c @@ -37,9 +37,9 @@ struct dcom_interface_pointer *dcom_interface_pointer_by_ipid(struct GUID *ipid) */ static WERROR RemoteActivation(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct RemoteActivation *r) { - struct CreateInstance *cr; + struct CreateInstance *cr = NULL; /*struct Release *ur;*/ - struct dcom_interface_p *o; + struct dcom_interface_p *o = NULL; int i; /* FIXME: CoGetClassObject() */ diff --git a/source4/torture/basic/denytest.c b/source4/torture/basic/denytest.c index 70d7a2b2a1..7979778c3f 100644 --- a/source4/torture/basic/denytest.c +++ b/source4/torture/basic/denytest.c @@ -1968,7 +1968,7 @@ BOOL torture_denydos_sharing(void) union smb_fileinfo finfo; const char *fname = "\\torture_denydos.txt"; NTSTATUS status; - int fnum1, fnum2; + int fnum1 = -1, fnum2 = -1; BOOL ret = True; union smb_setfileinfo sfinfo; TALLOC_CTX *mem_ctx; diff --git a/source4/torture/basic/locking.c b/source4/torture/basic/locking.c index c1dd598018..ba7d568706 100644 --- a/source4/torture/basic/locking.c +++ b/source4/torture/basic/locking.c @@ -790,7 +790,7 @@ BOOL torture_locktest7(void) struct smbcli_state *cli1; const char *fname = "\\lockt7.lck"; int fnum1; - int fnum2; + int fnum2 = -1; size_t size; char buf[200]; BOOL correct = False; diff --git a/source4/torture/dcom/simple.c b/source4/torture/dcom/simple.c index 68bf9be813..9dd750baad 100644 --- a/source4/torture/dcom/simple.c +++ b/source4/torture/dcom/simple.c @@ -29,7 +29,7 @@ BOOL torture_dcom_simple(void) { NTSTATUS status; - struct dcerpc_pipe *p; + struct dcerpc_pipe *p = NULL; TALLOC_CTX *mem_ctx; BOOL ret = True; struct GUID IID[2]; diff --git a/source4/torture/raw/acls.c b/source4/torture/raw/acls.c index 84d2238a9e..24f18e6cce 100644 --- a/source4/torture/raw/acls.c +++ b/source4/torture/raw/acls.c @@ -41,7 +41,7 @@ static BOOL test_sd(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) union smb_open io; const char *fname = BASEDIR "\\sd.txt"; BOOL ret = True; - int fnum; + int fnum = -1; union smb_fileinfo q; union smb_setfileinfo set; struct security_ace ace; @@ -249,7 +249,7 @@ static BOOL test_creator_sid(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) union smb_open io; const char *fname = BASEDIR "\\creator.txt"; BOOL ret = True; - int fnum; + int fnum = -1; union smb_fileinfo q; union smb_setfileinfo set; struct security_descriptor *sd, *sd_orig, *sd2; @@ -323,7 +323,7 @@ static BOOL test_creator_sid(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("set a sec desc allowing no write by owner\n"); sd = security_descriptor_create(mem_ctx, - NULL, NULL, + owner_sid, NULL, owner_sid, SEC_ACE_TYPE_ACCESS_ALLOWED, SEC_RIGHTS_FILE_READ | SEC_STD_ALL, @@ -440,7 +440,7 @@ static BOOL test_generic_bits(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) union smb_open io; const char *fname = BASEDIR "\\generic.txt"; BOOL ret = True; - int fnum, i; + int fnum = -1, i; union smb_fileinfo q; union smb_setfileinfo set; struct security_descriptor *sd, *sd_orig, *sd2; diff --git a/source4/torture/raw/eas.c b/source4/torture/raw/eas.c index 13ebea2401..044fe9ebb4 100644 --- a/source4/torture/raw/eas.c +++ b/source4/torture/raw/eas.c @@ -99,7 +99,7 @@ static BOOL test_eas(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) union smb_open io; const char *fname = BASEDIR "\\ea.txt"; BOOL ret = True; - int fnum; + int fnum = -1; printf("TESTING SETFILEINFO EA_SET\n"); diff --git a/source4/torture/raw/rename.c b/source4/torture/raw/rename.c index 6b16612698..c839100e7c 100644 --- a/source4/torture/raw/rename.c +++ b/source4/torture/raw/rename.c @@ -46,7 +46,7 @@ static BOOL test_mv(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) union smb_rename io; NTSTATUS status; BOOL ret = True; - int fnum; + int fnum = -1; const char *fname1 = BASEDIR "\\test1.txt"; const char *fname2 = BASEDIR "\\test2.txt"; union smb_open op; diff --git a/source4/torture/raw/streams.c b/source4/torture/raw/streams.c index 83ba08ee0a..7053f6c998 100644 --- a/source4/torture/raw/streams.c +++ b/source4/torture/raw/streams.c @@ -99,7 +99,7 @@ static BOOL test_stream_io(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) const char *fname = BASEDIR "\\stream.txt"; const char *sname1, *sname2; BOOL ret = True; - int fnum; + int fnum = -1; ssize_t retsize; sname1 = talloc_asprintf(mem_ctx, "%s:%s", fname, "Stream One"); diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c index e7c04b6ad1..821a823595 100644 --- a/source4/torture/rpc/samlogon.c +++ b/source4/torture/rpc/samlogon.c @@ -72,10 +72,8 @@ static NTSTATUS check_samlogon(struct samlogon_state *samlogon_state, struct netr_LogonSamLogonEx *r_ex = &samlogon_state->r_ex; struct netr_LogonSamLogonWithFlags *r_flags = &samlogon_state->r_flags; struct netr_NetworkInfo ninfo; - - struct netr_SamBaseInfo *base; - - uint16 validation_level; + struct netr_SamBaseInfo *base = NULL; + uint16 validation_level = 0; samlogon_state->r.in.logon.network = &ninfo; samlogon_state->r_ex.in.logon.network = &ninfo; diff --git a/source4/torture/rpc/xplogin.c b/source4/torture/rpc/xplogin.c index 8b7ccf115d..0007955e08 100644 --- a/source4/torture/rpc/xplogin.c +++ b/source4/torture/rpc/xplogin.c @@ -775,7 +775,7 @@ static NTSTATUS test_getallsids(struct smbcli_transport *transport, struct samr_Connect4 r4; struct policy_handle connect_handle, user_handle; struct policy_handle builtin_handle, domain_handle; - struct dom_sid *domain_sid; + struct dom_sid *domain_sid = NULL; struct dom_sid *user_sid; struct dom_sid *primary_group_sid; diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index ac427c4935..199f0429d6 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -159,7 +159,7 @@ static int binary_net(int argc, const char **argv) int argc_new; const char **argv_new; TALLOC_CTX *mem_ctx; - struct net_context *ctx; + struct net_context *ctx = NULL; poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP -- cgit