diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c
index b72fd1d9f370eec57da7c13659fc9a6866172662..075e942adda42b7c1fb9284b32787d69fd0458c6 100644
--- a/lustre/mds/handler.c
+++ b/lustre/mds/handler.c
@@ -325,7 +325,7 @@ struct dentry *mds_id2dentry(struct obd_device *obd, struct lustre_id *id,
         struct dentry *result;
         struct inode *inode;
         unsigned long ino = 0;
-        __u32 generation;
+        __u32 generation = 0;
         char idname[32];
 
         if (!id_ino(id) && id_fid(id)) {
@@ -349,6 +349,7 @@ struct dentry *mds_id2dentry(struct obd_device *obd, struct lustre_id *id,
         } else {
                 CERROR("invalid id for lookup "
                        DLID4"\n", OLID4(id));
+                LBUG();
         }
 
         if (ino == 0)
diff --git a/lustre/mds/mds_capa.c b/lustre/mds/mds_capa.c
index 63f9aecf8e4718e60c81d29c9f13326ffa985420..dd85ab63b40df86f2dd9da3bc1155a178f7db1bb 100644
--- a/lustre/mds/mds_capa.c
+++ b/lustre/mds/mds_capa.c
@@ -62,7 +62,7 @@ static int mds_write_capa_key(struct obd_device *obd, int force_sync)
         struct file *filp = mds->mds_capa_keys_filp;
         struct lvfs_run_ctxt saved;
         loff_t off = 0;
-        int i, rc;
+        int i, rc = 0;
         ENTRY;
 
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
diff --git a/lustre/obdfilter/filter_io.c b/lustre/obdfilter/filter_io.c
index 337347ff8bef4b39a6b39069b432c40ad99b23db..bb2d61a41dc737e3ee705296f9e1f1f309bfa394 100644
--- a/lustre/obdfilter/filter_io.c
+++ b/lustre/obdfilter/filter_io.c
@@ -498,13 +498,13 @@ static int filter_preprw_write(int cmd, struct obd_export *exp, struct obdo *oa,
                                struct obd_trans_info *oti)
 {
         int rc = 0, i, tot_bytes = 0, cleanup_phase = 0;
+        struct obd_device *obd = exp->exp_obd;
         struct niobuf_local *lnb = res;
         struct dentry *dentry = NULL;
         unsigned long now = jiffies;
         struct lvfs_run_ctxt saved;
         struct niobuf_remote *rnb;
         struct fsfilt_objinfo fso;
-        struct obd_device *obd;
         obd_size left;
         obd_uid uid;
         obd_gid gid;