Mainly fixing minor issues reported by sparse.
Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
Signed-off-by: Sage Weil <sage@newdream.net>
 
 #include <linux/errno.h>
 
+int ceph_armor(char *dst, const char *src, const char *end);
+int ceph_unarmor(char *dst, const char *src, const char *end);
+
 /*
  * base64 encode/decode.
  */
 
-const char *pem_key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+static const char *pem_key =
+       "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
 static int encode_bits(int c)
 {
 
        CEPH_AUTH_CEPHX
 };
 
-int ceph_auth_init_protocol(struct ceph_auth_client *ac, int protocol)
+static int ceph_auth_init_protocol(struct ceph_auth_client *ac, int protocol)
 {
        switch (protocol) {
        case CEPH_AUTH_NONE:
        return -ERANGE;
 }
 
-int ceph_build_auth_request(struct ceph_auth_client *ac,
-                          void *msg_buf, size_t msg_len)
+static int ceph_build_auth_request(struct ceph_auth_client *ac,
+                                  void *msg_buf, size_t msg_len)
 {
        struct ceph_mon_request_header *monhdr = msg_buf;
        void *p = monhdr + 1;
 
 /*
  * get existing (or insert new) ticket handler
  */
-struct ceph_x_ticket_handler *get_ticket_handler(struct ceph_auth_client *ac,
-                                                int service)
+static struct ceph_x_ticket_handler *
+get_ticket_handler(struct ceph_auth_client *ac, int service)
 {
        struct ceph_x_ticket_handler *th;
        struct ceph_x_info *xi = ac->private;
                auth->struct_v = 1;
                auth->key = 0;
                for (u = (u64 *)tmp_enc; u + 1 <= (u64 *)(tmp_enc + ret); u++)
-                       auth->key ^= *u;
+                       auth->key ^= *(__le64 *)u;
                dout(" server_challenge %llx client_challenge %llx key %llx\n",
                     xi->server_challenge, le64_to_cpu(auth->client_challenge),
                     le64_to_cpu(auth->key));
 
        kfree(b);
 }
 
-int ceph_buffer_alloc(struct ceph_buffer *b, int len, gfp_t gfp)
-{
-       b->vec.iov_base = kmalloc(len, gfp | __GFP_NOWARN);
-       if (b->vec.iov_base) {
-               b->is_vmalloc = false;
-       } else {
-               b->vec.iov_base = __vmalloc(len, gfp, PAGE_KERNEL);
-               b->is_vmalloc = true;
-       }
-       if (!b->vec.iov_base)
-               return -ENOMEM;
-       b->alloc_len = len;
-       b->vec.iov_len = len;
-       return 0;
-}
-
 int ceph_decode_buffer(struct ceph_buffer **b, void **p, void *end)
 {
        size_t len;
 
  */
 void __ceph_flush_snaps(struct ceph_inode_info *ci,
                        struct ceph_mds_session **psession)
+               __releases(ci->vfs_inode->i_lock)
+               __acquires(ci->vfs_inode->i_lock)
 {
        struct inode *inode = &ci->vfs_inode;
        int mds;
  */
 void ceph_check_caps(struct ceph_inode_info *ci, int flags,
                     struct ceph_mds_session *session)
-       __releases(session->s_mutex)
 {
        struct ceph_client *client = ceph_inode_to_client(&ci->vfs_inode);
        struct ceph_mds_client *mdsc = &client->mdsc;
                             struct ceph_mds_session *session,
                             struct ceph_cap *cap,
                             struct ceph_buffer *xattr_buf)
-       __releases(inode->i_lock)
-       __releases(session->s_mutex)
+               __releases(inode->i_lock)
 {
        struct ceph_inode_info *ci = ceph_inode(inode);
        int mds = session->s_mds;
 
        return crypto_alloc_blkcipher("cbc(aes)", 0, CRYPTO_ALG_ASYNC);
 }
 
-const u8 *aes_iv = "cephsageyudagreg";
+static const u8 *aes_iv = "cephsageyudagreg";
 
-int ceph_aes_encrypt(const void *key, int key_len, void *dst, size_t *dst_len,
-                    const void *src, size_t src_len)
+static int ceph_aes_encrypt(const void *key, int key_len,
+                           void *dst, size_t *dst_len,
+                           const void *src, size_t src_len)
 {
        struct scatterlist sg_in[2], sg_out[1];
        struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher();
        return 0;
 }
 
-int ceph_aes_encrypt2(const void *key, int key_len, void *dst, size_t *dst_len,
-                     const void *src1, size_t src1_len,
-                     const void *src2, size_t src2_len)
+static int ceph_aes_encrypt2(const void *key, int key_len, void *dst,
+                            size_t *dst_len,
+                            const void *src1, size_t src1_len,
+                            const void *src2, size_t src2_len)
 {
        struct scatterlist sg_in[3], sg_out[1];
        struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher();
        return 0;
 }
 
-int ceph_aes_decrypt(const void *key, int key_len, void *dst, size_t *dst_len,
-                    const void *src, size_t src_len)
+static int ceph_aes_decrypt(const void *key, int key_len,
+                           void *dst, size_t *dst_len,
+                           const void *src, size_t src_len)
 {
        struct scatterlist sg_in[1], sg_out[2];
        struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher();
        return 0;
 }
 
-int ceph_aes_decrypt2(const void *key, int key_len,
-                     void *dst1, size_t *dst1_len,
-                     void *dst2, size_t *dst2_len,
-                     const void *src, size_t src_len)
+static int ceph_aes_decrypt2(const void *key, int key_len,
+                            void *dst1, size_t *dst1_len,
+                            void *dst2, size_t *dst2_len,
+                            const void *src, size_t src_len)
 {
        struct scatterlist sg_in[1], sg_out[3];
        struct crypto_blkcipher *tfm = ceph_crypto_alloc_cipher();
 
                         const void *src2, size_t src2_len);
 
 /* armor.c */
-extern int ceph_armor(char *dst, const void *src, const void *end);
-extern int ceph_unarmor(void *dst, const char *src, const char *end);
+extern int ceph_armor(char *dst, const char *src, const char *end);
+extern int ceph_unarmor(char *dst, const char *src, const char *end);
 
 #endif
 
  */
 static inline void ceph_encode_addr(struct ceph_entity_addr *a)
 {
-       a->in_addr.ss_family = htons(a->in_addr.ss_family);
+       __be16 ss_family = htons(a->in_addr.ss_family);
+       a->in_addr.ss_family = *(__u16 *)&ss_family;
 }
 static inline void ceph_decode_addr(struct ceph_entity_addr *a)
 {
-       a->in_addr.ss_family = ntohs(a->in_addr.ss_family);
+       __be16 ss_family = *(__be16 *)&a->in_addr.ss_family;
+       a->in_addr.ss_family = ntohs(ss_family);
        WARN_ON(a->in_addr.ss_family == 512);
 }
 
 
  */
 static int __dcache_readdir(struct file *filp,
                            void *dirent, filldir_t filldir)
+               __releases(inode->i_lock)
+               __acquires(inode->i_lock)
 {
        struct inode *inode = filp->f_dentry->d_inode;
        struct ceph_file_info *fi = filp->private_data;
 
 /*
  * allocate a vector new pages
  */
-struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags)
+static struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags)
 {
        struct page **pages;
        int i;
        size_t len = iov->iov_len;
        struct inode *inode = filp->f_dentry->d_inode;
        struct ceph_inode_info *ci = ceph_inode(inode);
-       void *base = iov->iov_base;
+       void __user *base = iov->iov_base;
        ssize_t ret;
        int want, got = 0;
        int checkeof = 0, read = 0;
 
        destroy_workqueue(ceph_msgr_wq);
 }
 
-void ceph_msgr_flush()
+void ceph_msgr_flush(void)
 {
        flush_workqueue(ceph_msgr_wq);
 }
                   sizeof(con->peer_addr)) != 0 &&
            !(addr_is_blank(&con->actual_peer_addr.in_addr) &&
              con->actual_peer_addr.nonce == con->peer_addr.nonce)) {
-               pr_warning("wrong peer, want %s/%lld, got %s/%lld\n",
+               pr_warning("wrong peer, want %s/%d, got %s/%d\n",
                           pr_addr(&con->peer_addr.in_addr),
-                          le64_to_cpu(con->peer_addr.nonce),
+                          (int)le32_to_cpu(con->peer_addr.nonce),
                           pr_addr(&con->actual_peer_addr.in_addr),
-                          le64_to_cpu(con->actual_peer_addr.nonce));
+                          (int)le32_to_cpu(con->actual_peer_addr.nonce));
                con->error_msg = "wrong peer at address";
                return -1;
        }
 
        kfree(pi);
 }
 
-void __decode_pool(void **p, struct ceph_pg_pool_info *pi)
+static void __decode_pool(void **p, struct ceph_pg_pool_info *pi)
 {
        ceph_decode_copy(p, &pi->v, sizeof(pi->v));
        calc_pg_masks(pi);
 
 }
 
 static int __build_xattrs(struct inode *inode)
+       __releases(inode->i_lock)
+       __acquires(inode->i_lock)
 {
        u32 namelen;
        u32 numattr = 0;