diff --git a/lustre/include/liblustre.h b/lustre/include/liblustre.h
index 2fb2eec140a97438fb6354b380586cae5e36284f..2b3533a4687a2b6ea99778899964d6aef33fd20f 100644
--- a/lustre/include/liblustre.h
+++ b/lustre/include/liblustre.h
@@ -191,17 +191,17 @@ typedef int (write_proc_t)(struct file *file, const char *buffer,
 
 static __inline__ int ext2_set_bit(int nr, void *addr)
 {
-        return set_bit(nr, (long*)addr);
+        return set_bit(nr, addr);
 }
 
 static __inline__ int ext2_clear_bit(int nr, void *addr)
 {
-        return clear_bit(nr, (long*)addr);
+        return clear_bit(nr, addr);
 }
 
 static __inline__ int ext2_test_bit(int nr, void *addr)
 {
-        return test_bit(nr, (long*)addr);
+        return test_bit(nr, addr);
 }
 
 /* modules */
diff --git a/lustre/include/lustre/lustre_user.h b/lustre/include/lustre/lustre_user.h
index a703a7b31c357b6aa95a2bc0abbd536743294191..8c17bc596c784995894833986bacd1da6a46f29a 100644
--- a/lustre/include/lustre/lustre_user.h
+++ b/lustre/include/lustre/lustre_user.h
@@ -137,7 +137,7 @@ struct ll_recreate_obj {
 };
 
 struct obd_uuid {
-        __u8 uuid[40];
+        char uuid[40];
 };
 
 static inline int obd_uuid_equals(struct obd_uuid *u1, struct obd_uuid *u2)
@@ -182,7 +182,7 @@ static inline char *obd_uuid2str(struct obd_uuid *uuid)
 #define QFMT_LDISKFS 2  /* QFMT_VFS_V0(2), quota format for ldiskfs */
 
 struct if_quotacheck {
-        __u8                    obd_type[16];
+        char                    obd_type[16];
         struct obd_uuid         obd_uuid;
 };
 
@@ -276,7 +276,7 @@ struct if_quotactl {
         __u32                   qc_stat;
         struct obd_dqinfo       qc_dqinfo;
         struct obd_dqblk        qc_dqblk;
-        __u8                    obd_type[16];
+        char                    obd_type[16];
         struct obd_uuid         obd_uuid;
 };
 
diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h
index 416dc608e21a38efba8874820d560de94ff08b59..5c59d5b67b03a7524a0b526f598c44b31e6f34c9 100644
--- a/lustre/include/lustre_dlm.h
+++ b/lustre/include/lustre_dlm.h
@@ -664,7 +664,7 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, int flags,
                             ldlm_policy_data_t *, ldlm_mode_t mode,
                             struct lustre_handle *);
 struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
-                                        int *flags);
+                                        __u32 *flags);
 void ldlm_lock_cancel(struct ldlm_lock *lock);
 void ldlm_cancel_locks_for_export(struct obd_export *export);
 void ldlm_reprocess_all(struct ldlm_resource *res);
@@ -752,7 +752,7 @@ int ldlm_cli_enqueue_local(struct ldlm_namespace *ns,
                            struct lustre_handle *lockh);
 int ldlm_server_ast(struct lustre_handle *lockh, struct ldlm_lock_desc *new,
                     void *data, __u32 data_len);
-int ldlm_cli_convert(struct lustre_handle *, int new_mode, int *flags);
+int ldlm_cli_convert(struct lustre_handle *, int new_mode, __u32 *flags);
 int ldlm_cli_update_pool(struct ptlrpc_request *req);
 int ldlm_handle_convert0(struct ptlrpc_request *req,
                          const struct ldlm_request *dlm_req);
diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c
index f8f7742ebb308c4653bdab5ed5c218aa5043ed91..88e1ef2c8833265c1b2c4ad5ee7618402c6092d5 100644
--- a/lustre/ldlm/ldlm_lock.c
+++ b/lustre/ldlm/ldlm_lock.c
@@ -1630,7 +1630,7 @@ void ldlm_cancel_locks_for_export(struct obd_export *exp)
 }
 
 struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
-                                        int *flags)
+                                        __u32 *flags)
 {
         struct list_head rpc_list = LIST_HEAD_INIT(rpc_list);
         struct ldlm_resource *res;
diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c
index ed32e21e8038a92411fc550eb62b473c51f40988..32a8d69427c01c7751c9ad8bd3533e9011555f8e 100644
--- a/lustre/ldlm/ldlm_lockd.c
+++ b/lustre/ldlm/ldlm_lockd.c
@@ -975,7 +975,7 @@ existing_lock:
         if (dlm_req->lock_desc.l_resource.lr_type == LDLM_EXTENT)
                 lock->l_req_extent = lock->l_policy_data.l_extent;
 
-        err = ldlm_lock_enqueue(ns, &lock, cookie, &flags);
+        err = ldlm_lock_enqueue(ns, &lock, cookie, (int *)&flags);
         if (err)
                 GOTO(out, err);
 
diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c
index adcc5d71d859fbc62b191ceb06238e2d71ee3a4f..852cea8c7d4434a00d846304d28cebea67db861f 100644
--- a/lustre/ldlm/ldlm_request.c
+++ b/lustre/ldlm/ldlm_request.c
@@ -716,7 +716,7 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp,
 }
 
 static int ldlm_cli_convert_local(struct ldlm_lock *lock, int new_mode,
-                                  int *flags)
+                                  __u32 *flags)
 {
         struct ldlm_resource *res;
         int rc;
@@ -743,7 +743,7 @@ static int ldlm_cli_convert_local(struct ldlm_lock *lock, int new_mode,
  * conversion of locks which are on the waiting or converting queue */
 /* Caller of this code is supposed to take care of lock readers/writers
    accounting */
-int ldlm_cli_convert(struct lustre_handle *lockh, int new_mode, int *flags)
+int ldlm_cli_convert(struct lustre_handle *lockh, int new_mode, __u32 *flags)
 {
         struct ldlm_request *body;
         struct ldlm_reply *reply;
diff --git a/lustre/liblustre/genlib.sh b/lustre/liblustre/genlib.sh
index 863547895f87be107f9cd08cc439046aea825c1d..dcc0009b8d94ed3e1e7572c1717d257f499904e0 100755
--- a/lustre/liblustre/genlib.sh
+++ b/lustre/liblustre/genlib.sh
@@ -108,7 +108,7 @@ OS=`uname`
 if test x$OS = xAIX; then
 $LD -shared -o $CWD/liblustre.so $ALL_OBJS -lpthread -Xlinker -bnoipath ../../libsyscall.so
 else
-$LD -shared -o $CWD/liblustre.so $ALL_OBJS $CAP_LIBS $PTHREAD_LIBS
+$LD -shared -nostdlib -o $CWD/liblustre.so $ALL_OBJS $CAP_LIBS $PTHREAD_LIBS
 fi
 
 rm -rf $sysio_tmp
diff --git a/lustre/liblustre/lutil.c b/lustre/liblustre/lutil.c
index 17ec86a4ec2011a5b4fbddb6098c427637b63987..65a13780b98f0ee31023b068a1eebb22fa681cb2 100644
--- a/lustre/liblustre/lutil.c
+++ b/lustre/liblustre/lutil.c
@@ -129,7 +129,7 @@ void liblustre_init_random()
         ll_srand(tv.tv_sec ^ __swab32(seed[0]), tv.tv_usec ^__swab32(getpid()));
 }
 
-static void init_capability(int *res)
+static void init_capability(__u32 *res)
 {
 #ifdef HAVE_LIBCAP
         cap_t syscap;
diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c
index 73292c8c290526d13165bb4a71ec3b363840a99b..430d6ac10b0ae5870bf88f17b7d96c5ccfc60be5 100644
--- a/lustre/lov/lov_obd.c
+++ b/lustre/lov/lov_obd.c
@@ -2378,7 +2378,7 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen,
                 GOTO(out, rc = -ENXIO);
         } else if (KEY_IS(KEY_LAST_ID)) {
                 struct obd_id_info *info = val;
-                int size = sizeof(obd_id);
+                __u32 size = sizeof(obd_id);
                 struct lov_tgt_desc *tgt;
 
                 LASSERT(*vallen == sizeof(struct obd_id_info));
diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c
index 5a760bdb7cd44fba1fa71a867fad79f3bd37ab56..68686a10c99e7db33f0331fee79bbce4e4643537 100644
--- a/lustre/osc/osc_request.c
+++ b/lustre/osc/osc_request.c
@@ -940,7 +940,7 @@ static obd_count osc_checksum_bulk(int nob, obd_count pg_count,
 
         LASSERT (pg_count > 0);
         while (nob > 0 && pg_count > 0) {
-                char *ptr = cfs_kmap(pga[i]->pg);
+                unsigned char *ptr = cfs_kmap(pga[i]->pg);
                 int off = pga[i]->off & ~CFS_PAGE_MASK;
                 int count = pga[i]->count > nob ? nob : pga[i]->count;
 
diff --git a/lustre/ptlrpc/events.c b/lustre/ptlrpc/events.c
index 41352f1f79d4b21feb52b9c7bbe31987f4df40d8..affe7dd3c92d855fc84e5bcb7bfd7a17760dfb77 100644
--- a/lustre/ptlrpc/events.c
+++ b/lustre/ptlrpc/events.c
@@ -354,12 +354,12 @@ int ptlrpc_uuid_to_peer (struct obd_uuid *uuid,
                          lnet_process_id_t *peer, lnet_nid_t *self)
 {
         int               best_dist = 0;
-        int               best_order = 0;
+        __u32             best_order = 0;
         int               count = 0;
         int               rc = -ENOENT;
         int               portals_compatibility;
         int               dist;
-        int               order;
+        __u32             order;
         lnet_nid_t        dst_nid;
         lnet_nid_t        src_nid;
 
@@ -379,7 +379,6 @@ int ptlrpc_uuid_to_peer (struct obd_uuid *uuid,
                         break;
                 }
 
-                LASSERT (order >= 0);
                 if (rc < 0 ||
                     dist < best_dist ||
                     (dist == best_dist && order < best_order)) {
diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c
index 716f01e9b26952971ce3ef2ab52f0ddf590c229f..146dd55b2dcbe24f46b95ec8496372137c0bcbd2 100644
--- a/lustre/ptlrpc/pack_generic.c
+++ b/lustre/ptlrpc/pack_generic.c
@@ -550,7 +550,7 @@ int lustre_shrink_msg_v1(struct lustre_msg_v1 *msg, int segment,
         }
 
 out:
-        return lustre_msg_size_v1(msg->lm_bufcount, msg->lm_buflens);
+        return lustre_msg_size_v1(msg->lm_bufcount, (int *)msg->lm_buflens);
 }
 
 int lustre_shrink_msg_v2(struct lustre_msg_v2 *msg, int segment,
@@ -588,7 +588,7 @@ int lustre_shrink_msg_v2(struct lustre_msg_v2 *msg, int segment,
         }
 
 out:
-        return lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens);
+        return lustre_msg_size_v2(msg->lm_bufcount, (int *)msg->lm_buflens);
 }
 
 /*