From a750ad42a8403bc697a71f13271ee7fae79bd865 Mon Sep 17 00:00:00 2001 From: zab Date: Thu, 13 Nov 2003 20:21:48 +0000 Subject: [PATCH] Silence most of the warnings in the x86_64 build, and kill some Real Bugs in the process. (sanity checked in an x86 uml build, as well) - include linux/init.h from some modules that use __init and company - x86_64 has 64 bit longs but uses 'long long' for u64 in the kernel. we add its own specific section to LP*64 definitions. Sadly, there are still a huge number of warnings from this gcc when we try to LP*64 print uint64_t obdo arguments. - use min_t in some defines to avoid the duplicate const prefacing that comes with nesting min() - LPX64 printing -1UL doesn't work so well - i_nlink can be any of unsigned short, int, or long. when printing cast to unsigned long. - kern_addr_valid takes a 'unsigned long' argument and shifts it.. sigh. - don't #define EXPORT_SYMTAB in the source, that's the job of the kernel makefiles - x86_64/suse has THREAD_SIZE defined in userspace - s/long flags/unsigned long flags/. Again. - va_list ap = NULL; is not legal, as far as I know. it doesn't seem to actually do anything in this code path either. - x86_64 passes CONFIG_X86 but had thread->rsp as the stack pointer. this code is going away eventually anyway. - print a pointer with %p, not %x - some portals callback pointer definitions used size_t while some nal's functions used ptl_size_t in the function defintions. I switched the functions over to avoid pushing changes on all the nals. --- lnet/include/linux/kp30.h | 17 ++++++++++++----- lnet/klnds/toelnd/toenal.c | 2 +- lnet/klnds/toelnd/toenal_cb.c | 10 +++++----- lnet/libcfs/debug.c | 7 +++++-- lnet/ulnds/procapi.c | 6 +++--- lnet/ulnds/proclib.c | 6 +++--- lnet/ulnds/socklnd/procapi.c | 6 +++--- lnet/ulnds/socklnd/proclib.c | 6 +++--- lnet/ulnds/socklnd/tcplnd.c | 4 ++-- lnet/ulnds/tcplnd.c | 4 ++-- lustre/ldlm/ldlm_lib.c | 2 +- lustre/portals/include/linux/kp30.h | 17 ++++++++++++----- lustre/portals/knals/toenal/toenal.c | 2 +- lustre/portals/knals/toenal/toenal_cb.c | 10 +++++----- lustre/portals/libcfs/debug.c | 7 +++++-- lustre/portals/unals/procapi.c | 6 +++--- lustre/portals/unals/proclib.c | 6 +++--- lustre/portals/unals/tcpnal.c | 4 ++-- 18 files changed, 71 insertions(+), 51 deletions(-) diff --git a/lnet/include/linux/kp30.h b/lnet/include/linux/kp30.h index f3d0d61..4b95b6c 100644 --- a/lnet/include/linux/kp30.h +++ b/lnet/include/linux/kp30.h @@ -74,8 +74,10 @@ extern unsigned int portal_cerror; #ifdef __KERNEL__ # include /* THREAD_SIZE */ -#else -# define THREAD_SIZE 8192 +#else +# ifndef THREAD_SIZE /* x86_64 has THREAD_SIZE in userspace */ +# define THREAD_SIZE 8192 +# endif #endif #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5) @@ -1108,14 +1110,19 @@ void kportal_put_ni (int nal); # endif #endif -#if (BITS_PER_LONG == 32 || __WORDSIZE == 32) +#if defined(__x86_64__) +# define LPU64 "%Lu" +# define LPD64 "%Ld" +# define LPX64 "%#Lx" +# define LPSZ "%lu" +# define LPSSZ "%ld" +#elif (BITS_PER_LONG == 32 || __WORDSIZE == 32) # define LPU64 "%Lu" # define LPD64 "%Ld" # define LPX64 "%#Lx" # define LPSZ "%u" # define LPSSZ "%d" -#endif -#if (BITS_PER_LONG == 64 || __WORDSIZE == 64) +#elif (BITS_PER_LONG == 64 || __WORDSIZE == 64) # define LPU64 "%lu" # define LPD64 "%ld" # define LPX64 "%#lx" diff --git a/lnet/klnds/toelnd/toenal.c b/lnet/klnds/toelnd/toenal.c index a85b281..07b93cb 100644 --- a/lnet/klnds/toelnd/toenal.c +++ b/lnet/klnds/toelnd/toenal.c @@ -210,7 +210,7 @@ error: int ktoenal_close_sock(ptl_nid_t nid) { - long flags; + unsigned long flags; ksock_conn_t *conn; LIST_HEAD (death_row); struct list_head *tmp; diff --git a/lnet/klnds/toelnd/toenal_cb.c b/lnet/klnds/toelnd/toenal_cb.c index f7fa794..3af9e33 100644 --- a/lnet/klnds/toelnd/toenal_cb.c +++ b/lnet/klnds/toelnd/toenal_cb.c @@ -140,7 +140,7 @@ ktoenal_dist(nal_cb_t *nal, ptl_nid_t nid, unsigned long *dist) ksock_ltx_t * ktoenal_get_ltx (int may_block) { - long flags; + unsigned long flags; ksock_ltx_t *ltx = NULL; for (;;) @@ -268,7 +268,7 @@ ktoenal_recvmsg(struct file *sock, struct iovec *iov, int niov, int toread) } void -ktoenal_process_transmit (ksock_conn_t *conn, long *irq_flags) +ktoenal_process_transmit (ksock_conn_t *conn, unsigned long *irq_flags) { ksock_tx_t *tx = list_entry (conn->ksnc_tx_queue.next, ksock_tx_t, tx_list); int rc; @@ -358,7 +358,7 @@ ktoenal_process_transmit (ksock_conn_t *conn, long *irq_flags) void ktoenal_launch_packet (ksock_conn_t *conn, ksock_tx_t *tx) { - long flags; + unsigned long flags; int nob = tx->tx_nob; struct iovec *iov = tx->tx_iov; int niov = 1; @@ -541,7 +541,7 @@ ktoenal_fmb_callback (void *arg, int error) ksock_fmb_t *fmb = (ksock_fmb_t *)arg; ptl_hdr_t *hdr = (ptl_hdr_t *) page_address(fmb->fmb_pages[0]); ksock_conn_t *conn; - long flags; + unsigned long flags; CDEBUG (D_NET, "routed packet from "LPX64" to "LPX64": %d\n", hdr->src_nid, hdr->dest_nid, error); @@ -790,7 +790,7 @@ ktoenal_new_packet (ksock_conn_t *conn, int nob_to_skip) } void -ktoenal_process_receive (ksock_conn_t *conn, long *irq_flags) +ktoenal_process_receive (ksock_conn_t *conn, unsigned long *irq_flags) { ksock_fmb_t *fmb; int len; diff --git a/lnet/libcfs/debug.c b/lnet/libcfs/debug.c index f27924e..6e2c1ca 100644 --- a/lnet/libcfs/debug.c +++ b/lnet/libcfs/debug.c @@ -775,7 +775,6 @@ portals_debug_msg(int subsys, int mask, char *file, const char *fn, /* If this is the first time, leave a marker in the * output */ debug_daemon_state.overlapped = 1; - ap = NULL; format = "DEBUG MARKER: Debug buffer overlapped\n"; printk(KERN_ERR "LustreError: debug daemon buffer " "overlapped\n"); @@ -982,7 +981,11 @@ extern int lookup_symbol(unsigned long address, char *buf, int buflen); char *portals_debug_dumpstack(void) { +#if defined(__x86_64__) + unsigned long esp = current->thread.rsp; +#else unsigned long esp = current->thread.esp; +#endif unsigned long *stack = (unsigned long *)&esp; int size; unsigned long addr; @@ -1012,7 +1015,7 @@ char *portals_debug_dumpstack(void) /* fix length + sizeof('\0') */ <= pbuf + strlen(buffer) + 28 + 1) break; - size = sprintf(pbuf, "([<%08lx>] %s (0x%x)) ", + size = sprintf(pbuf, "([<%08lx>] %s (0x%p)) ", addr, buffer, stack-1); } pbuf += size; diff --git a/lnet/ulnds/procapi.c b/lnet/ulnds/procapi.c index f4820b2..d897058 100644 --- a/lnet/ulnds/procapi.c +++ b/lnet/ulnds/procapi.c @@ -53,8 +53,8 @@ lib_fini(b->nal_cb);\ return(PTL_SEGV);\ } -static int procbridge_forward(nal_t *n, int id, void *args, ptl_size_t args_len, - void *ret, ptl_size_t ret_len) +static int procbridge_forward(nal_t *n, int id, void *args, size_t args_len, + void *ret, size_t ret_len) { bridge b=(bridge)n->nal_data; procbridge p=(procbridge)b->local; @@ -108,7 +108,7 @@ static int procbridge_shutdown(nal_t *n, int ni) /* Function: validate * useless stub */ -static int procbridge_validate(nal_t *nal, void *base, ptl_size_t extent) +static int procbridge_validate(nal_t *nal, void *base, size_t extent) { return(0); } diff --git a/lnet/ulnds/proclib.c b/lnet/ulnds/proclib.c index 99afe66..89b67ad 100644 --- a/lnet/ulnds/proclib.c +++ b/lnet/ulnds/proclib.c @@ -48,7 +48,7 @@ static int nal_write(nal_cb_t *nal, void *private, user_ptr dst_addr, void *src_addr, - ptl_size_t len) + size_t len) { memcpy(dst_addr, src_addr, len); return 0; @@ -65,7 +65,7 @@ static int nal_read(nal_cb_t * nal, } static void *nal_malloc(nal_cb_t *nal, - ptl_size_t len) + size_t len) { void *buf = malloc(len); return buf; @@ -73,7 +73,7 @@ static void *nal_malloc(nal_cb_t *nal, static void nal_free(nal_cb_t *nal, void *buf, - ptl_size_t len) + size_t len) { free(buf); } diff --git a/lnet/ulnds/socklnd/procapi.c b/lnet/ulnds/socklnd/procapi.c index f4820b2..d897058 100644 --- a/lnet/ulnds/socklnd/procapi.c +++ b/lnet/ulnds/socklnd/procapi.c @@ -53,8 +53,8 @@ lib_fini(b->nal_cb);\ return(PTL_SEGV);\ } -static int procbridge_forward(nal_t *n, int id, void *args, ptl_size_t args_len, - void *ret, ptl_size_t ret_len) +static int procbridge_forward(nal_t *n, int id, void *args, size_t args_len, + void *ret, size_t ret_len) { bridge b=(bridge)n->nal_data; procbridge p=(procbridge)b->local; @@ -108,7 +108,7 @@ static int procbridge_shutdown(nal_t *n, int ni) /* Function: validate * useless stub */ -static int procbridge_validate(nal_t *nal, void *base, ptl_size_t extent) +static int procbridge_validate(nal_t *nal, void *base, size_t extent) { return(0); } diff --git a/lnet/ulnds/socklnd/proclib.c b/lnet/ulnds/socklnd/proclib.c index 99afe66..89b67ad 100644 --- a/lnet/ulnds/socklnd/proclib.c +++ b/lnet/ulnds/socklnd/proclib.c @@ -48,7 +48,7 @@ static int nal_write(nal_cb_t *nal, void *private, user_ptr dst_addr, void *src_addr, - ptl_size_t len) + size_t len) { memcpy(dst_addr, src_addr, len); return 0; @@ -65,7 +65,7 @@ static int nal_read(nal_cb_t * nal, } static void *nal_malloc(nal_cb_t *nal, - ptl_size_t len) + size_t len) { void *buf = malloc(len); return buf; @@ -73,7 +73,7 @@ static void *nal_malloc(nal_cb_t *nal, static void nal_free(nal_cb_t *nal, void *buf, - ptl_size_t len) + size_t len) { free(buf); } diff --git a/lnet/ulnds/socklnd/tcplnd.c b/lnet/ulnds/socklnd/tcplnd.c index d6b5ed0..5daee9c0 100644 --- a/lnet/ulnds/socklnd/tcplnd.c +++ b/lnet/ulnds/socklnd/tcplnd.c @@ -120,8 +120,8 @@ int tcpnal_recv(nal_cb_t *n, lib_msg_t *cookie, unsigned int niov, struct iovec *iov, - ptl_size_t mlen, - ptl_size_t rlen) + size_t mlen, + size_t rlen) { if (mlen) { diff --git a/lnet/ulnds/tcplnd.c b/lnet/ulnds/tcplnd.c index d6b5ed0..5daee9c0 100644 --- a/lnet/ulnds/tcplnd.c +++ b/lnet/ulnds/tcplnd.c @@ -120,8 +120,8 @@ int tcpnal_recv(nal_cb_t *n, lib_msg_t *cookie, unsigned int niov, struct iovec *iov, - ptl_size_t mlen, - ptl_size_t rlen) + size_t mlen, + size_t rlen) { if (mlen) { diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 106fcb6..7c6aadf 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -291,7 +291,7 @@ int client_disconnect_export(struct obd_export *exp, int failover) if (!obd) { CERROR("invalid export for disconnect: " "exp %p cookie "LPX64"\n", exp, - exp ? exp->exp_handle.h_cookie : -1UL); + exp ? exp->exp_handle.h_cookie : -1); RETURN(-EINVAL); } diff --git a/lustre/portals/include/linux/kp30.h b/lustre/portals/include/linux/kp30.h index f3d0d61..4b95b6c 100644 --- a/lustre/portals/include/linux/kp30.h +++ b/lustre/portals/include/linux/kp30.h @@ -74,8 +74,10 @@ extern unsigned int portal_cerror; #ifdef __KERNEL__ # include /* THREAD_SIZE */ -#else -# define THREAD_SIZE 8192 +#else +# ifndef THREAD_SIZE /* x86_64 has THREAD_SIZE in userspace */ +# define THREAD_SIZE 8192 +# endif #endif #define LUSTRE_TRACE_SIZE (THREAD_SIZE >> 5) @@ -1108,14 +1110,19 @@ void kportal_put_ni (int nal); # endif #endif -#if (BITS_PER_LONG == 32 || __WORDSIZE == 32) +#if defined(__x86_64__) +# define LPU64 "%Lu" +# define LPD64 "%Ld" +# define LPX64 "%#Lx" +# define LPSZ "%lu" +# define LPSSZ "%ld" +#elif (BITS_PER_LONG == 32 || __WORDSIZE == 32) # define LPU64 "%Lu" # define LPD64 "%Ld" # define LPX64 "%#Lx" # define LPSZ "%u" # define LPSSZ "%d" -#endif -#if (BITS_PER_LONG == 64 || __WORDSIZE == 64) +#elif (BITS_PER_LONG == 64 || __WORDSIZE == 64) # define LPU64 "%lu" # define LPD64 "%ld" # define LPX64 "%#lx" diff --git a/lustre/portals/knals/toenal/toenal.c b/lustre/portals/knals/toenal/toenal.c index a85b281..07b93cb 100644 --- a/lustre/portals/knals/toenal/toenal.c +++ b/lustre/portals/knals/toenal/toenal.c @@ -210,7 +210,7 @@ error: int ktoenal_close_sock(ptl_nid_t nid) { - long flags; + unsigned long flags; ksock_conn_t *conn; LIST_HEAD (death_row); struct list_head *tmp; diff --git a/lustre/portals/knals/toenal/toenal_cb.c b/lustre/portals/knals/toenal/toenal_cb.c index f7fa794..3af9e33 100644 --- a/lustre/portals/knals/toenal/toenal_cb.c +++ b/lustre/portals/knals/toenal/toenal_cb.c @@ -140,7 +140,7 @@ ktoenal_dist(nal_cb_t *nal, ptl_nid_t nid, unsigned long *dist) ksock_ltx_t * ktoenal_get_ltx (int may_block) { - long flags; + unsigned long flags; ksock_ltx_t *ltx = NULL; for (;;) @@ -268,7 +268,7 @@ ktoenal_recvmsg(struct file *sock, struct iovec *iov, int niov, int toread) } void -ktoenal_process_transmit (ksock_conn_t *conn, long *irq_flags) +ktoenal_process_transmit (ksock_conn_t *conn, unsigned long *irq_flags) { ksock_tx_t *tx = list_entry (conn->ksnc_tx_queue.next, ksock_tx_t, tx_list); int rc; @@ -358,7 +358,7 @@ ktoenal_process_transmit (ksock_conn_t *conn, long *irq_flags) void ktoenal_launch_packet (ksock_conn_t *conn, ksock_tx_t *tx) { - long flags; + unsigned long flags; int nob = tx->tx_nob; struct iovec *iov = tx->tx_iov; int niov = 1; @@ -541,7 +541,7 @@ ktoenal_fmb_callback (void *arg, int error) ksock_fmb_t *fmb = (ksock_fmb_t *)arg; ptl_hdr_t *hdr = (ptl_hdr_t *) page_address(fmb->fmb_pages[0]); ksock_conn_t *conn; - long flags; + unsigned long flags; CDEBUG (D_NET, "routed packet from "LPX64" to "LPX64": %d\n", hdr->src_nid, hdr->dest_nid, error); @@ -790,7 +790,7 @@ ktoenal_new_packet (ksock_conn_t *conn, int nob_to_skip) } void -ktoenal_process_receive (ksock_conn_t *conn, long *irq_flags) +ktoenal_process_receive (ksock_conn_t *conn, unsigned long *irq_flags) { ksock_fmb_t *fmb; int len; diff --git a/lustre/portals/libcfs/debug.c b/lustre/portals/libcfs/debug.c index f27924e..6e2c1ca 100644 --- a/lustre/portals/libcfs/debug.c +++ b/lustre/portals/libcfs/debug.c @@ -775,7 +775,6 @@ portals_debug_msg(int subsys, int mask, char *file, const char *fn, /* If this is the first time, leave a marker in the * output */ debug_daemon_state.overlapped = 1; - ap = NULL; format = "DEBUG MARKER: Debug buffer overlapped\n"; printk(KERN_ERR "LustreError: debug daemon buffer " "overlapped\n"); @@ -982,7 +981,11 @@ extern int lookup_symbol(unsigned long address, char *buf, int buflen); char *portals_debug_dumpstack(void) { +#if defined(__x86_64__) + unsigned long esp = current->thread.rsp; +#else unsigned long esp = current->thread.esp; +#endif unsigned long *stack = (unsigned long *)&esp; int size; unsigned long addr; @@ -1012,7 +1015,7 @@ char *portals_debug_dumpstack(void) /* fix length + sizeof('\0') */ <= pbuf + strlen(buffer) + 28 + 1) break; - size = sprintf(pbuf, "([<%08lx>] %s (0x%x)) ", + size = sprintf(pbuf, "([<%08lx>] %s (0x%p)) ", addr, buffer, stack-1); } pbuf += size; diff --git a/lustre/portals/unals/procapi.c b/lustre/portals/unals/procapi.c index f4820b2..d897058 100644 --- a/lustre/portals/unals/procapi.c +++ b/lustre/portals/unals/procapi.c @@ -53,8 +53,8 @@ lib_fini(b->nal_cb);\ return(PTL_SEGV);\ } -static int procbridge_forward(nal_t *n, int id, void *args, ptl_size_t args_len, - void *ret, ptl_size_t ret_len) +static int procbridge_forward(nal_t *n, int id, void *args, size_t args_len, + void *ret, size_t ret_len) { bridge b=(bridge)n->nal_data; procbridge p=(procbridge)b->local; @@ -108,7 +108,7 @@ static int procbridge_shutdown(nal_t *n, int ni) /* Function: validate * useless stub */ -static int procbridge_validate(nal_t *nal, void *base, ptl_size_t extent) +static int procbridge_validate(nal_t *nal, void *base, size_t extent) { return(0); } diff --git a/lustre/portals/unals/proclib.c b/lustre/portals/unals/proclib.c index 99afe66..89b67ad 100644 --- a/lustre/portals/unals/proclib.c +++ b/lustre/portals/unals/proclib.c @@ -48,7 +48,7 @@ static int nal_write(nal_cb_t *nal, void *private, user_ptr dst_addr, void *src_addr, - ptl_size_t len) + size_t len) { memcpy(dst_addr, src_addr, len); return 0; @@ -65,7 +65,7 @@ static int nal_read(nal_cb_t * nal, } static void *nal_malloc(nal_cb_t *nal, - ptl_size_t len) + size_t len) { void *buf = malloc(len); return buf; @@ -73,7 +73,7 @@ static void *nal_malloc(nal_cb_t *nal, static void nal_free(nal_cb_t *nal, void *buf, - ptl_size_t len) + size_t len) { free(buf); } diff --git a/lustre/portals/unals/tcpnal.c b/lustre/portals/unals/tcpnal.c index d6b5ed0..5daee9c0 100644 --- a/lustre/portals/unals/tcpnal.c +++ b/lustre/portals/unals/tcpnal.c @@ -120,8 +120,8 @@ int tcpnal_recv(nal_cb_t *n, lib_msg_t *cookie, unsigned int niov, struct iovec *iov, - ptl_size_t mlen, - ptl_size_t rlen) + size_t mlen, + size_t rlen) { if (mlen) { -- 1.8.3.1