summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/client/client.c2
-rw-r--r--source4/include/smb_macros.h77
-rw-r--r--source4/lib/netif/interface.c5
-rw-r--r--source4/lib/pidfile.c2
-rw-r--r--source4/lib/util.c6
-rw-r--r--source4/libcli/ldap/ldap_client.c4
-rw-r--r--source4/param/loadparm.c2
-rw-r--r--source4/rpc_server/netlogon/dcerpc_netlogon.c4
-rw-r--r--source4/smb_server/conn.c2
-rw-r--r--source4/smb_server/service.c5
-rw-r--r--source4/torture/rpc/drsuapi.c2
-rw-r--r--source4/torture/torture.c2
-rw-r--r--source4/utils/net/net_time.c2
13 files changed, 31 insertions, 84 deletions
diff --git a/source4/client/client.c b/source4/client/client.c
index 986f35b971..59311a35d8 100644
--- a/source4/client/client.c
+++ b/source4/client/client.c
@@ -216,7 +216,7 @@ static void send_message(void)
int l=0;
int c;
- ZERO_ARRAY(msg);
+ ZERO_STRUCT(msg);
for (l=0;l<maxlen && (c=fgetc(stdin))!=EOF;l++) {
if (c == '\n')
diff --git a/source4/include/smb_macros.h b/source4/include/smb_macros.h
index 0f13341821..276076955f 100644
--- a/source4/include/smb_macros.h
+++ b/source4/include/smb_macros.h
@@ -24,29 +24,6 @@
#ifndef _SMB_MACROS_H
#define _SMB_MACROS_H
-/* Misc bit macros */
-#define BOOLSTR(b) ((b) ? "Yes" : "No")
-#define BITSETB(ptr,bit) ((((char *)ptr)[0] & (1<<(bit)))!=0)
-#define BITSETW(ptr,bit) ((SVAL(ptr,0) & (1<<(bit)))!=0)
-
-/* for readability... */
-#define IS_DOS_READONLY(test_mode) (((test_mode) & aRONLY) != 0)
-#define IS_DOS_DIR(test_mode) (((test_mode) & aDIR) != 0)
-#define IS_DOS_ARCHIVE(test_mode) (((test_mode) & aARCH) != 0)
-#define IS_DOS_SYSTEM(test_mode) (((test_mode) & aSYSTEM) != 0)
-#define IS_DOS_HIDDEN(test_mode) (((test_mode) & aHIDDEN) != 0)
-
-#ifndef SAFE_FREE /* Oh no this is also defined in tdb.h */
-
-/**
- * Free memory if the pointer and zero the pointer.
- *
- * @note You are explicitly allowed to pass NULL pointers -- they will
- * always be ignored.
- **/
-#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); (x)=NULL;} } while(0)
-#endif
-
/* zero a structure */
#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
@@ -56,10 +33,6 @@
/* zero a structure given a pointer to the structure - no zero check */
#define ZERO_STRUCTPN(x) memset((char *)(x), 0, sizeof(*(x)))
-/* zero an array - note that sizeof(array) must work - ie. it must not be a
- pointer */
-#define ZERO_ARRAY(x) memset((char *)(x), 0, sizeof(x))
-
/* pointer difference macro */
#define PTR_DIFF(p1,p2) ((ptrdiff_t)(((const char *)(p1)) - (const char *)(p2)))
@@ -73,23 +46,6 @@
#define SMB_ASSERT_ARRAY(a,n) SMB_ASSERT((sizeof(a)/sizeof((a)[0])) >= (n))
-/* the service number for the [globals] defaults */
-#define GLOBAL_SECTION_SNUM (-1)
-/* translates a connection number into a service number */
-#define SNUM(conn) ((conn)?(conn)->service:GLOBAL_SECTION_SNUM)
-
-
-/* access various service details */
-#define SERVICE(snum) (lp_servicename(snum))
-#define PRINTERNAME_NOTUSED(snum) (lp_printername(snum))
-#define CAN_WRITE(conn) (!conn->read_only)
-#define VALID_SNUM(snum) (lp_snum_ok(snum))
-#define GUEST_OK(snum) (VALID_SNUM(snum) && lp_guest_ok(snum))
-
-/* these are the datagram types */
-#define DGRAM_DIRECT_UNIQUE 0x10
-
-
/* REWRITE TODO: remove these smb_xxx macros */
#define smb_buf(buf) (((char *)(buf)) + MIN_SMB_SIZE + CVAL(buf,HDR_WCT+4)*2)
@@ -97,29 +53,6 @@
#define _smb_setlen(buf,len) do {(buf)[0] = 0; (buf)[1] = ((len)&0x10000)>>16; \
(buf)[2] = ((len)&0xFF00)>>8; (buf)[3] = (len)&0xFF;} while (0)
-/*******************************************************************
-find the difference in milliseconds between two struct timeval
-values
-********************************************************************/
-
-#define TvalDiff(tvalold,tvalnew) \
- (((tvalnew)->tv_sec - (tvalold)->tv_sec)*1000 + \
- ((int)(tvalnew)->tv_usec - (int)(tvalold)->tv_usec)/1000)
-
-/****************************************************************************
-true if two IP addresses are equal
-****************************************************************************/
-
-#define ip_equal(ip1,ip2) ((ip1).s_addr == (ip2).s_addr)
-#define ipv4_equal(ip1,ip2) ((ip1).addr == (ip2).addr)
-
-/*******************************************************************
-copy an IP address from one buffer to another
-********************************************************************/
-
-#define putip(dest,src) memcpy(dest,src,4)
-
-
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif
@@ -132,5 +65,15 @@ copy an IP address from one buffer to another
#define ABS(a) ((a)>0?(a):(-(a)))
#endif
+#ifndef SAFE_FREE /* Oh no this is also defined in tdb.h */
+/**
+ * Free memory if the pointer and zero the pointer.
+ *
+ * @note You are explicitly allowed to pass NULL pointers -- they will
+ * always be ignored.
+ **/
+#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); (x)=NULL;} } while(0)
+#endif
+
#endif /* _SMB_MACROS_H */
diff --git a/source4/lib/netif/interface.c b/source4/lib/netif/interface.c
index 31354e359a..2d90df43cf 100644
--- a/source4/lib/netif/interface.c
+++ b/source4/lib/netif/interface.c
@@ -272,8 +272,9 @@ BOOL interfaces_changed(void)
BOOL ismyip(struct ipv4_addr ip)
{
struct interface *i;
- for (i=local_interfaces;i;i=i->next)
- if (ipv4_equal(i->ip,ip)) return True;
+ for (i=local_interfaces;i;i=i->next) {
+ if (i->ip.addr == ip.addr) return True;
+ }
return False;
}
diff --git a/source4/lib/pidfile.c b/source4/lib/pidfile.c
index ff05c0606e..b1866ee6af 100644
--- a/source4/lib/pidfile.c
+++ b/source4/lib/pidfile.c
@@ -44,7 +44,7 @@ pid_t pidfile_pid(const char *name)
return 0;
}
- ZERO_ARRAY(pidstr);
+ ZERO_STRUCT(pidstr);
if (read(fd, pidstr, sizeof(pidstr)-1) <= 0) {
goto noproc;
diff --git a/source4/lib/util.c b/source4/lib/util.c
index d95924670f..93559d9518 100644
--- a/source4/lib/util.c
+++ b/source4/lib/util.c
@@ -410,7 +410,7 @@ uint32_t interpret_addr(const char *str)
DEBUG(3,("sys_gethostbyname: host address is invalid for host %s\n",str));
return 0;
}
- putip((char *)&res,(char *)hp->h_addr);
+ memcpy((char *)&res,(char *)hp->h_addr, 4);
}
if (res == (uint32_t)-1)
@@ -436,9 +436,7 @@ struct ipv4_addr interpret_addr2(const char *str)
BOOL is_zero_ip(struct ipv4_addr ip)
{
- uint32_t a;
- putip((char *)&a,(char *)&ip);
- return(a == 0);
+ return ip.addr == 0;
}
/*******************************************************************
diff --git a/source4/libcli/ldap/ldap_client.c b/source4/libcli/ldap/ldap_client.c
index 11815ddd6d..e3904c7a6b 100644
--- a/source4/libcli/ldap/ldap_client.c
+++ b/source4/libcli/ldap/ldap_client.c
@@ -223,7 +223,7 @@ static int open_socket_out(int type, struct ipv4_addr *addr, int port, int timeo
if (type != SOCK_STREAM) return(res);
memset((char *)&sock_out,'\0',sizeof(sock_out));
- putip((char *)&sock_out.sin_addr,(char *)addr);
+ sock_out.sin_addr.s_addr = addr->addr;
sock_out.sin_port = htons( port );
sock_out.sin_family = PF_INET;
@@ -385,7 +385,7 @@ struct ldap_connection *ldap_connect(TALLOC_CTX *mem_ctx, const char *url)
return NULL;
}
- putip((char *)&ip, (char *)hp->h_addr);
+ memcpy((char *)&ip, (char *)hp->h_addr, 4);
conn->sock = open_socket_out(SOCK_STREAM, &ip, conn->port, LDAP_CONNECTION_TIMEOUT);
if (conn->sock < 0) {
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 121821b542..bd4bb8af04 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -2506,6 +2506,8 @@ BOOL lp_set_option(const char *option)
}
+#define BOOLSTR(b) ((b) ? "Yes" : "No")
+
/***************************************************************************
Print a parameter of the specified type.
***************************************************************************/
diff --git a/source4/rpc_server/netlogon/dcerpc_netlogon.c b/source4/rpc_server/netlogon/dcerpc_netlogon.c
index 67048e4a3d..bb16ed54c6 100644
--- a/source4/rpc_server/netlogon/dcerpc_netlogon.c
+++ b/source4/rpc_server/netlogon/dcerpc_netlogon.c
@@ -535,7 +535,7 @@ static NTSTATUS netr_LogonSamLogonEx(struct dcesrv_call_state *dce_call, TALLOC_
NT_STATUS_HAVE_NO_MEMORY(sam->domain_sid);
sam->domain_sid->num_auths--;
- ZERO_ARRAY(sam->unknown);
+ ZERO_STRUCT(sam->unknown);
ZERO_STRUCT(sam->key);
if (server_info->user_session_key.length == sizeof(sam->key.key)) {
@@ -1101,7 +1101,7 @@ static NTSTATUS netr_ServerPasswordSet2(struct dcesrv_call_state *dce_call, TALL
False, /* This is not considered a password change */
False, /* don't restrict this password change (match w2k3) */
NULL);
- ZERO_ARRAY(new_pass);
+ ZERO_STRUCT(new_pass);
NT_STATUS_NOT_OK_RETURN(nt_status);
ret = samdb_replace(sam_ctx, mem_ctx, mod);
diff --git a/source4/smb_server/conn.c b/source4/smb_server/conn.c
index 45c5376e25..6ca8e4286c 100644
--- a/source4/smb_server/conn.c
+++ b/source4/smb_server/conn.c
@@ -52,7 +52,7 @@ static int smbsrv_tcon_destructor(void *ptr)
DEBUG(3,("%s closed connection to service %s\n",
socket_get_peer_addr(tcon->smb_conn->connection->socket, tcon),
- lp_servicename(SNUM(tcon))));
+ lp_servicename(tcon->service)));
/* tell the ntvfs backend that we are disconnecting */
ntvfs_disconnect(tcon);
diff --git a/source4/smb_server/service.c b/source4/smb_server/service.c
index 180deaf8c5..bb74a5c2d9 100644
--- a/source4/smb_server/service.c
+++ b/source4/smb_server/service.c
@@ -73,7 +73,7 @@ static int find_service(const char *service)
iService = lp_servicenumber(service);
- if (iService >= 0 && !VALID_SNUM(iService)) {
+ if (iService >= 0 && !lp_snum_ok(iService)) {
DEBUG(0,("Invalid snum %d for %s\n",iService, service));
iService = -1;
}
@@ -117,7 +117,8 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req,
/* init ntvfs function pointers */
status = ntvfs_init_connection(req, type);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("ntvfs_init_connection failed for service %s\n", lp_servicename(SNUM(tcon))));
+ DEBUG(0, ("ntvfs_init_connection failed for service %s\n",
+ lp_servicename(tcon->service)));
return status;
}
diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c
index f386c84a91..e10c088e36 100644
--- a/source4/torture/rpc/drsuapi.c
+++ b/source4/torture/rpc/drsuapi.c
@@ -790,7 +790,7 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
r.in.req.req1.info->unknown1 = 32;
r.in.req.req1.info->unknown2 = 120;
ZERO_STRUCT(r.in.req.req1.info->guid1);
- ZERO_ARRAY(r.in.req.req1.info->unknown3);
+ ZERO_STRUCT(r.in.req.req1.info->unknown3);
r.in.req.req1.info->nc_dn = priv->domain_obj_dn?priv->domain_obj_dn:"";
r.in.req.req1.guid1 = priv->dcinfo.ntds_guid;
r.in.req.req1.string1 = NULL;
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index b7ca730d1f..6b92bce691 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -527,6 +527,8 @@ static BOOL rw_torture2(struct smbcli_state *c1, struct smbcli_state *c2)
return correct;
}
+#define BOOLSTR(b) ((b) ? "Yes" : "No")
+
static BOOL run_readwritetest(void)
{
struct smbcli_state *cli1, *cli2;
diff --git a/source4/utils/net/net_time.c b/source4/utils/net/net_time.c
index d2df76bc5d..ec3bc0519f 100644
--- a/source4/utils/net/net_time.c
+++ b/source4/utils/net/net_time.c
@@ -64,7 +64,7 @@ int net_time(struct net_context *ctx, int argc, const char **argv)
return -1;
}
- ZERO_ARRAY(timestr);
+ ZERO_STRUCT(timestr);
tm = localtime(&r.generic.out.time);
strftime(timestr, sizeof(timestr)-1, "%c %Z",tm);