--- a/tools/libxc/xc_tmem.c
+++ b/tools/libxc/xc_tmem.c
@@ -390,7 +390,8 @@ static int xc_tmem_restore_new_pool(
 
 int xc_tmem_restore(xc_interface *xch, int dom, int io_fd)
 {
-    uint32_t save_max_pools, save_version;
+    uint32_t save_version;
+    uint32_t __attribute__((__unused__)) save_max_pools;
     uint32_t this_max_pools, this_version;
     uint32_t pool_id;
     uint32_t minusone;
--- a/tools/libxc/xc_domain_restore.c
+++ b/tools/libxc/xc_domain_restore.c
@@ -1087,7 +1087,6 @@ int xc_domain_restore(xc_interface *xch,
     int vcpuextstate = 0;
     uint32_t vcpuextstate_size = 0;
     unsigned long mfn, pfn;
-    unsigned int prev_pc;
     int nraces = 0;
 
     /* The new domain's shared-info frame number. */
@@ -1251,7 +1250,6 @@ int xc_domain_restore(xc_interface *xch,
      * Now simply read each saved frame into its new machine frame.
      * We uncanonicalise page tables as we go.
      */
-    prev_pc = 0;
 
     n = m = 0;
  loadpages:
--- a/tools/misc/gtraceview.c
+++ b/tools/misc/gtraceview.c
@@ -622,7 +622,8 @@ void crt_init(void)
 void nr_addch(int nr, int ch)
 {
     int i;
-    int y, x;
+    int x;
+    int __attribute__((__unused__)) y;
     getyx(stdscr, y, x);
     for (i = 0; i < nr; i++) {
         if (x == COLS-1)
--- a/tools/xcutils/xc_restore.c
+++ b/tools/xcutils/xc_restore.c
@@ -19,7 +19,8 @@ int
 main(int argc, char **argv)
 {
     unsigned int domid, store_evtchn, console_evtchn;
-    unsigned int hvm, pae, apic;
+    unsigned int hvm, pae;
+    unsigned int __attribute__((__unused__)) apic;
     xc_interface *xch;
     int io_fd, ret;
     int superpages;
--- a/tools/firmware/rombios/32bit/tcgbios/tcgbios.c
+++ b/tools/firmware/rombios/32bit/tcgbios/tcgbios.c
@@ -1064,7 +1064,7 @@ uint32_t HashLogEvent32(struct hlei *hle
 	uint32_t rc = 0;
 	uint16_t size;
 	uint32_t logdataptr;
-	uint32_t logdatalen;
+	uint32_t __attribute__((__unused__)) logdatalen;
 	uint32_t hashdataptr;
 	uint32_t hashdatalen;
 
--- a/tools/console/client/main.c
+++ b/tools/console/client/main.c
@@ -277,7 +277,8 @@ int main(int argc, char **argv)
 
 	};
 	char *dom_path = NULL, *path = NULL;
-	int spty, xsfd;
+	int spty;
+	int __attribute__((__unused__)) xsfd;
 	struct xs_handle *xs;
 	char *end;
 	console_type type = CONSOLE_INVAL;
--- a/tools/xenstat/xentop/xentop.c
+++ b/tools/xenstat/xentop/xentop.c
@@ -272,7 +272,8 @@ static void fail(const char *str)
 /* Return the row containing the cursor. */
 static int current_row(void)
 {
-	int y, x;
+	int __attribute__((__unused__)) x;
+	int y;
 	getyx(stdscr, y, x);
 	return y;
 }
@@ -280,7 +281,8 @@ static int current_row(void)
 /* Return the number of lines on the screen. */
 static int lines(void)
 {
-	int y, x;
+	int __attribute__((__unused__)) x;
+	int y;
 	getmaxyx(stdscr, y, x);
 	return y;
 }
--- a/tools/libxl/libxlu_cfg.c
+++ b/tools/libxl/libxlu_cfg.c
@@ -348,7 +348,7 @@ char *xlu__cfgl_dequote(CfgParseContext 
 
 #define NUMERIC_CHAR(minlen,maxlen,base,basetext) do{                        \
                 char numbuf[(maxlen)+1], *ep;                                \
-                unsigned long val;                                           \
+                unsigned long __attribute__((__unused__)) val;               \
                                                                              \
                 strncpy(numbuf,p,(maxlen));                                  \
                 numbuf[(maxlen)]= 0;                                         \
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -221,7 +221,7 @@ int libxl_domain_rename(libxl_ctx *ctx, 
 int libxl_domain_resume(libxl_ctx *ctx, uint32_t domid)
 {
     libxl__gc gc = LIBXL_INIT_GC(ctx);
-    int rc = 0;
+    int __attribute__((__unused__)) rc = 0;
 
     if (libxl__domain_is_hvm(ctx, domid)) {
         LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Called domain_resume on "
@@ -1291,7 +1291,7 @@ libxl_nicinfo *libxl_list_nics(libxl_ctx
 {
     libxl__gc gc = LIBXL_INIT_GC(ctx);
     char *dompath, *nic_path_fe;
-    char **l, **list;
+    char **l;
     char *val, *tok;
     unsigned int nb_nics, i;
     libxl_nicinfo *res, *nics;
@@ -1299,7 +1299,7 @@ libxl_nicinfo *libxl_list_nics(libxl_ctx
     dompath = libxl__xs_get_dompath(&gc, domid);
     if (!dompath)
         goto err;
-    list = l = libxl__xs_directory(&gc, XBT_NULL,
+    l = libxl__xs_directory(&gc, XBT_NULL,
                            libxl__sprintf(&gc, "%s/device/vif", dompath), &nb_nics);
     if (!l)
         goto err;
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -240,7 +240,7 @@ static int libxl_create_pci_backend(libx
     flexarray_t *front = NULL;
     flexarray_t *back = NULL;
     libxl__device device;
-    int ret = ERROR_NOMEM, i;
+    int i;
 
     front = flexarray_make(16, 1);
     if (!front)
@@ -249,8 +249,6 @@ static int libxl_create_pci_backend(libx
     if (!back)
         goto out;
 
-    ret = 0;
-
     LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Creating pci backend");
 
     /* add pci device */
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -265,14 +265,13 @@ int libxl__build_hvm(libxl_ctx *ctx, uin
               libxl_domain_build_info *info, libxl_domain_build_state *state)
 {
     libxl__gc gc = LIBXL_INIT_GC(ctx);
-    int ret, rc = ERROR_INVAL;
+    int ret;
 
     if (info->kernel.mapped) {
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "libxl__build_hvm kernel cannot be mmapped");
         goto out;
     }
 
-    rc = ERROR_FAIL;
     ret = xc_hvm_build_target_mem(
         ctx->xch,
         domid,
@@ -290,7 +289,6 @@ int libxl__build_hvm(libxl_ctx *ctx, uin
         LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, ret, "hvm build set params failed");
         goto out;
     }
-    rc = 0;
 out:
     libxl__free_all(&gc);
     return 0;
--- a/tools/libxl/libxl_utils.c
+++ b/tools/libxl/libxl_utils.c
@@ -531,7 +531,7 @@ int libxl_devid_to_device_disk(libxl_ctx
     libxl__gc gc = LIBXL_INIT_GC(ctx);
     char *endptr, *val;
     char *dompath, *diskpath, *be_path;
-    unsigned int devid_n;
+    unsigned int __attribute__((__unused__)) devid_n;
     int rc = ERROR_INVAL;
 
     devid_n = strtoul(devid, &endptr, 10);
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -5448,7 +5448,7 @@ int main_cpupoollist(int argc, char **ar
         {"cpus", 0, 0, 'c'},
         {0, 0, 0, 0}
     };
-    int opt_long = 0;
+    int __attribute__((__unused__)) opt_long = 0;
     int opt_cpus = 0;
     const char *pool = NULL;
     libxl_cpupoolinfo *poolinfo;
--- a/tools/debugger/gdbsx/gx/gx_comm.c
+++ b/tools/debugger/gdbsx/gx/gx_comm.c
@@ -163,7 +163,7 @@ readchar(void)
     static char buf[BUFSIZ];
     static int bufcnt = 0;
     static char *bufp;
-    uint64_t ll;
+    uint64_t __attribute__((__unused__)) ll;
 
     if (bufcnt-- > 0)
         return *bufp++ & 0x7f;
--- a/tools/python/xen/lowlevel/checkpoint/libcheckpoint.c
+++ b/tools/python/xen/lowlevel/checkpoint/libcheckpoint.c
@@ -820,7 +820,7 @@ static int create_suspend_thread(checkpo
 
 static void stop_suspend_thread(checkpoint_state* s)
 {
-  int err;
+  int __attribute__((__unused__)) err;
 
   s->done = 1;
 
--- a/tools/python/xen/lowlevel/netlink/libnetlink.c
+++ b/tools/python/xen/lowlevel/netlink/libnetlink.c
@@ -433,7 +433,8 @@ int rtnl_from_file(FILE *rtnl, rtnl_filt
        nladdr.nl_groups = 0;
 
        while (1) {
-               int err, len, type;
+               int err, len;
+               int __attribute__((__unused__)) type;
                int l;
 
                status = fread(&buf, 1, sizeof(*h), rtnl);
--- a/xen/arch/x86/msi.c
+++ b/xen/arch/x86/msi.c
@@ -745,7 +745,7 @@ static void __pci_disable_msi(struct msi
 {
     struct pci_dev *dev;
     int pos;
-    u16 control;
+    u16 __attribute__((__unused__)) control;
     u8 bus, slot, func;
 
     dev = entry->dev;
--- a/xen/arch/x86/microcode_amd.c
+++ b/xen/arch/x86/microcode_amd.c
@@ -164,7 +164,7 @@ static int apply_microcode(int cpu)
 static int get_next_ucode_from_buffer_amd(void *mc, const void *buf,
                                          size_t size, unsigned long *offset)
 {
-    struct microcode_header_amd *mc_header;
+    struct microcode_header_amd __attribute__((__unused__)) *mc_header;
     size_t total_size;
     const uint8_t *bufp = buf;
     unsigned long off;
--- a/xen/common/cpupool.c
+++ b/xen/common/cpupool.c
@@ -356,7 +356,7 @@ int cpupool_add_domain(struct domain *d,
 {
     struct cpupool *c;
     int rc = 1;
-    int n_dom = 0;
+    int __attribute__((__unused__)) n_dom = 0;
 
     if ( poolid == CPUPOOLID_NONE )
         return 0;
@@ -380,8 +380,8 @@ int cpupool_add_domain(struct domain *d,
  */
 void cpupool_rm_domain(struct domain *d)
 {
-    int cpupool_id;
-    int n_dom;
+    int __attribute__((__unused__)) cpupool_id;
+    int __attribute__((__unused__)) n_dom;
 
     if ( d->cpupool == NULL )
         return;
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -765,7 +765,7 @@ __gnttab_unmap_common(
     struct domain   *ld, *rd;
     struct active_grant_entry *act;
     s16              rc = 0;
-    u32              old_pin;
+    u32 __attribute__((__unused__)) old_pin;
 
     ld = current->domain;
 
--- a/xen/common/kexec.c
+++ b/xen/common/kexec.c
@@ -563,7 +563,8 @@ static int kexec_exec(XEN_GUEST_HANDLE(v
 {
     xen_kexec_exec_t exec;
     xen_kexec_image_t *image;
-    int base, bit, pos, ret = -EINVAL;
+    int base, bit, pos;
+    int __attribute__((__unused__)) ret = -EINVAL;
 
     if ( unlikely(copy_from_guest(&exec, uarg, 1)) )
         return -EFAULT;
--- a/xen/drivers/passthrough/vtd/intremap.c
+++ b/xen/drivers/passthrough/vtd/intremap.c
@@ -367,7 +367,7 @@ unsigned int io_apic_read_remap_rte(
     unsigned int ioapic_pin = (reg - 0x10) / 2;
     int index;
     struct IO_xAPIC_route_entry old_rte = { 0 };
-    struct IO_APIC_route_remap_entry *remap_rte;
+    struct IO_APIC_route_remap_entry __attribute__((__unused__)) *remap_rte;
     int rte_upper = (reg & 1) ? 1 : 0;
     struct iommu *iommu = ioapic_to_iommu(IO_APIC_ID(apic));
     struct ir_ctrl *ir_ctrl = iommu_ir_ctrl(iommu);
@@ -850,7 +850,7 @@ int iommu_enable_x2apic_IR(void)
 
     for_each_drhd_unit ( drhd )
     {
-        struct qi_ctrl *qi_ctrl = NULL;
+        struct qi_ctrl __attribute__((__unused__)) *qi_ctrl = NULL;
 
         iommu = drhd->iommu;
         qi_ctrl = iommu_qi_ctrl(iommu);
--- a/xen/common/sched_credit2.c
+++ b/xen/common/sched_credit2.c
@@ -1854,7 +1854,8 @@ static void deactivate_runqueue(struct c
 
 static void init_pcpu(const struct scheduler *ops, int cpu)
 {
-    int rqi, old_rqi, flags;
+    int rqi, flags;
+    int __attribute__((__unused__)) old_rqi;
     struct csched_private *prv = CSCHED_PRIV(ops);
     struct csched_runqueue_data *rqd;
     spinlock_t *old_lock;
--- a/xen/common/unlzo.c
+++ b/xen/common/unlzo.c
@@ -68,7 +68,7 @@ static int INIT parse_header(u8 *input, 
 {
 	int l;
 	u8 *parse = input;
-	u8 level = 0;
+	u8 __attribute__((__unused__)) level = 0;
 	u16 version;
 
 	/* read magic: 9 first bits */
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -1001,7 +1001,8 @@ static void local_time_calibration(void)
      * System timestamps, extrapolated from local and master oscillators,
      * taken during this calibration and the previous calibration.
      */
-    s_time_t prev_local_stime, curr_local_stime;
+    s_time_t curr_local_stime;
+    s_time_t __attribute__((__unused__)) prev_local_stime;
     s_time_t prev_master_stime, curr_master_stime;
 
     /* TSC timestamps taken during this calibration and prev calibration. */
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -348,7 +348,7 @@ static void __devinit init_amd(struct cp
 {
 	u32 l, h;
 	int mbytes = num_physpages >> (20-PAGE_SHIFT);
-	int r;
+	int __attribute__((__unused__)) r;
 
 #ifdef CONFIG_SMP
 	unsigned long long value;
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -2338,7 +2338,7 @@ p2m_remove_page(struct p2m_domain *p2m, 
                 unsigned int page_order)
 {
     unsigned long i;
-    mfn_t mfn_return;
+    mfn_t __attribute__((__unused__)) mfn_return;
     p2m_type_t t;
     p2m_access_t a;
 
@@ -2407,7 +2407,7 @@ guest_physmap_mark_populate_on_demand(st
     struct p2m_domain *p2m = p2m_get_hostp2m(d);
     unsigned long i;
     p2m_type_t ot;
-    mfn_t omfn;
+    mfn_t __attribute__((__unused__)) omfn;
     int pod_count = 0;
     int rc = 0;
 
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -59,7 +59,7 @@ static int hvmemul_do_io(
     ioreq_t *p = get_ioreq(curr);
     unsigned long ram_gfn = paddr_to_pfn(ram_gpa);
     p2m_type_t p2mt;
-    mfn_t ram_mfn;
+    mfn_t __attribute__((__unused__)) ram_mfn;
     int rc;
 
     /* Check for paged out page */
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -253,7 +253,8 @@ void hvm_migrate_timers(struct vcpu *v)
 
 void hvm_migrate_pirqs(struct vcpu *v)
 {
-    int pirq, irq;
+    int pirq;
+    int __attribute__((__unused__)) irq;
     struct irq_desc *desc;
     struct domain *d = v->domain;
     struct hvm_irq_dpci *hvm_irq_dpci = d->arch.hvm_domain.irq.dpci;
@@ -3588,7 +3589,7 @@ long do_hvm_op(unsigned long op, XEN_GUE
         {
             p2m_type_t t;
             p2m_type_t nt;
-            mfn_t mfn;
+            mfn_t __attribute__((__unused__)) mfn;
             mfn = gfn_to_mfn_unshare(p2m, pfn, &t, 0);
             if ( p2m_is_paging(t) )
             {
--- a/xen/arch/x86/acpi/cpu_idle.c
+++ b/xen/arch/x86/acpi/cpu_idle.c
@@ -273,7 +273,7 @@ static void acpi_processor_ffh_cstate_en
 
 static void acpi_idle_do_entry(struct acpi_processor_cx *cx)
 {
-    int unused;
+    int __attribute__((__unused__)) unused;
 
     switch ( cx->entry_method )
     {
--- a/xen/arch/x86/cpu/intel.c
+++ b/xen/arch/x86/cpu/intel.c
@@ -35,7 +35,7 @@ struct movsl_mask movsl_mask __read_most
  */
 static void __devinit set_cpuidmask(const struct cpuinfo_x86 *c)
 {
-	const char *extra = "";
+	const char __attribute__((__unused__)) *extra = "";
 
 	if (!~(opt_cpuid_mask_ecx & opt_cpuid_mask_edx &
 	       opt_cpuid_mask_ext_ecx & opt_cpuid_mask_ext_edx))
--- a/xen/arch/x86/cpu/intel_cacheinfo.c
+++ b/xen/arch/x86/cpu/intel_cacheinfo.c
@@ -170,7 +170,8 @@ unsigned int __cpuinit init_intel_cachei
 	unsigned int trace = 0, l1i = 0, l1d = 0, l2 = 0, l3 = 0; /* Cache sizes */
 	unsigned int new_l1d = 0, new_l1i = 0; /* Cache sizes from cpuid(4) */
 	unsigned int new_l2 = 0, new_l3 = 0, i; /* Cache sizes from cpuid(4) */
-	unsigned int l2_id = 0, l3_id = 0, num_threads_sharing, index_msb;
+	unsigned int num_threads_sharing, index_msb;
+	unsigned int __attribute__((__unused__)) l2_id = 0, l3_id = 0;
 
 	if (c->cpuid_level > 3) {
 		static int is_initialized;
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -376,7 +376,7 @@ int mem_sharing_debug_gfn(struct domain 
 {
     p2m_type_t p2mt;
     mfn_t mfn;
-    struct page_info *page;
+    struct page_info __attribute__((__unused__)) *page;
 
     mfn = gfn_to_mfn(p2m_get_hostp2m(d), gfn, &p2mt);
     page = mfn_to_page(mfn);
--- a/xen/arch/x86/hvm/viridian.c
+++ b/xen/arch/x86/hvm/viridian.c
@@ -270,7 +270,7 @@ int rdmsr_viridian_regs(uint32_t idx, ui
 int viridian_hypercall(struct cpu_user_regs *regs)
 {
     int mode = hvm_guest_x86_mode(current);
-    unsigned long input_params_gpa, output_params_gpa;
+    unsigned long __attribute__((__unused__)) input_params_gpa, output_params_gpa;
     uint16_t status = HV_STATUS_SUCCESS;
 
     union hypercall_input {
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -4900,7 +4900,7 @@ static int ptwr_emulated_update(
 {
     unsigned long mfn;
     unsigned long unaligned_addr = addr;
-    struct page_info *page;
+    struct page_info __attribute__((__unused__)) *page;
     l1_pgentry_t pte, ol1e, nl1e, *pl1e;
     struct vcpu *v = current;
     struct domain *d = v->domain;
--- a/xen/arch/x86/x86_64/mm.c
+++ b/xen/arch/x86/x86_64/mm.c
@@ -435,7 +435,8 @@ void destroy_m2p_mapping(struct mem_hota
 static int setup_compat_m2p_table(struct mem_hotadd_info *info)
 {
     unsigned long i, va, smap, emap, rwva, epfn = info->epfn;
-    unsigned int n, memflags;
+    unsigned int n;
+    unsigned int __attribute__((__unused__)) memflags;
     l3_pgentry_t *l3_ro_mpt = NULL;
     l2_pgentry_t *l2_ro_mpt = NULL;
     struct page_info *l1_pg;
--- a/xen/arch/x86/cpu/mcheck/mce.c
+++ b/xen/arch/x86/cpu/mcheck/mce.c
@@ -151,7 +151,6 @@ static struct mcinfo_bank *mca_init_bank
                                          struct mc_info *mi, int bank)
 {
     struct mcinfo_bank *mib;
-    uint64_t addr=0, misc = 0;
 
     if (!mi)
         return NULL;
@@ -170,7 +169,6 @@ static struct mcinfo_bank *mca_init_bank
     mib->common.size = sizeof (struct mcinfo_bank);
     mib->mc_bank = bank;
 
-    addr = misc = 0;
     if (mib->mc_status & MCi_STATUS_MISCV)
         mib->mc_misc = mca_rdmsr(MSR_IA32_MCx_MISC(bank));
 
@@ -281,7 +279,7 @@ mctelem_cookie_t mcheck_mca_logout(enum 
     recover = (mc_recoverable_scan)? 1: 0;
 
     for (i = 0; i < 32 && i < nr_mce_banks; i++) {
-        struct mcinfo_bank *mib;  /* on stack */
+        struct mcinfo_bank __attribute__((__unused__)) *mib;  /* on stack */
 
         /* Skip bank if corresponding bit in bankmask is clear */
         if (!mcabanks_test(i, bankmask))
@@ -1215,7 +1213,7 @@ static void x86_mc_msrinject(void *data)
 {
     struct xen_mc_msrinject *mci = data;
     struct mcinfo_msr *msr;
-    struct cpuinfo_x86 *c;
+    struct cpuinfo_x86 __attribute__((__unused__)) *c;
     uint64_t hwcr = 0;
     int intpose;
     int i;
--- a/xen/common/tmem.c
+++ b/xen/common/tmem.c
@@ -1351,7 +1351,8 @@ obj_unlock:
 static int tmem_evict(void)
 {
     client_t *client = tmh_client_from_current();
-    pgp_t *pgp = NULL, *pgp2, *pgp_del;
+    pgp_t *pgp = NULL, *pgp2;
+    pgp_t __attribute__((__unused__)) *pgp_del;
     obj_t *obj;
     pool_t *pool;
     int ret = 0;
@@ -1588,7 +1589,8 @@ static NOINLINE int do_tmem_put(pool_t *
               pagesize_t pfn_offset, pagesize_t len, void *cva)
 {
     obj_t *obj = NULL, *objfound = NULL, *objnew = NULL;
-    pgp_t *pgp = NULL, *pgpdel = NULL;
+    pgp_t *pgp = NULL;
+    pgp_t __attribute__((__unused__)) *pgpdel = NULL;
     client_t *client = pool->client;
     int ret = client->frozen ? -EFROZEN : -ENOMEM;
 
--- a/xen/common/tmem_xen.c
+++ b/xen/common/tmem_xen.c
@@ -177,7 +177,7 @@ EXPORT int tmh_copy_from_client(pfp_t *p
 EXPORT int tmh_compress_from_client(tmem_cli_mfn_t cmfn,
     void **out_va, size_t *out_len, void *cli_va)
 {
-    int ret = 0;
+    int __attribute__((__unused__)) ret = 0;
     unsigned char *dmem = this_cpu(dstmem);
     unsigned char *wmem = this_cpu(workmem);
     pfp_t *cli_pfp = NULL;
@@ -237,7 +237,7 @@ EXPORT int tmh_decompress_to_client(tmem
     pfp_t *cli_pfp = NULL;
     size_t out_len = PAGE_SIZE;
     bool_t tmemc = cli_va != NULL; /* if true, cli_va is control-op buffer */
-    int ret;
+    int __attribute__((__unused__)) ret;
 
     if ( !tmemc )
     {
@@ -366,15 +366,17 @@ static void tmh_persistent_pool_page_put
 EXPORT tmh_client_t *tmh_client_init(cli_id_t cli_id)
 {
     tmh_client_t *tmh;
+#ifndef __i386__
     char name[5];
     int i, shift;
+#endif
 
     if ( (tmh = xmalloc(tmh_client_t)) == NULL )
         return NULL;
+#ifndef __i386__
     for (i = 0, shift = 12; i < 4; shift -=4, i++)
         name[i] = (((unsigned short)cli_id >> shift) & 0xf) + '0';
     name[4] = '\0';
-#ifndef __i386__
     tmh->persistent_pool = xmem_pool_create(name, tmh_persistent_pool_page_get,
         tmh_persistent_pool_page_put, PAGE_SIZE, 0, PAGE_SIZE);
     if ( tmh->persistent_pool == NULL )
--- a/xen/arch/x86/cpu/mcheck/vmce.c
+++ b/xen/arch/x86/cpu/mcheck/vmce.c
@@ -574,7 +574,7 @@ int is_vmce_ready(struct mcinfo_bank *ba
  */
 int unmmap_broken_page(struct domain *d, mfn_t mfn, unsigned long gfn)
 {
-    mfn_t r_mfn;
+    mfn_t __attribute__((__unused__)) r_mfn;
     struct p2m_domain *p2m;
     p2m_type_t pt;
 
--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -124,7 +124,7 @@ set_shadow_status(struct vcpu *v, mfn_t 
 /* Put a shadow into the hash table */
 {
     struct domain *d = v->domain;
-    int res;
+    int __attribute__((__unused__)) res;
 
     SHADOW_PRINTK("d=%d, v=%d, gmfn=%05lx, type=%08x, smfn=%05lx\n",
                    d->domain_id, v->vcpu_id, mfn_x(gmfn),
@@ -4446,7 +4446,7 @@ sh_update_cr3(struct vcpu *v, int do_loc
 int sh_rm_write_access_from_sl1p(struct vcpu *v, mfn_t gmfn, 
                                  mfn_t smfn, unsigned long off)
 {
-    int r;
+    int __attribute__((__unused__)) r;
     shadow_l1e_t *sl1p, sl1e;
     struct page_info *sp;
 
--- a/xen/arch/x86/domain_build.c
+++ b/xen/arch/x86/domain_build.c
@@ -375,8 +375,7 @@ int __init construct_dom0(
         return rc;
 
     /* compatibility check */
-    compatible = 0;
-    compat32   = 0;
+    compatible = compat32 = 0;
     machine = elf_uval(&elf, elf.ehdr, e_machine);
     switch (CONFIG_PAGING_LEVELS) {
     case 3: /* x86_32p */
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -1784,7 +1784,11 @@ static int emulate_privileged_op(struct 
     struct vcpu *v = current;
     unsigned long *reg, eip = regs->eip;
     u8 opcode, modrm_reg = 0, modrm_rm = 0, rep_prefix = 0, lock = 0, rex = 0;
+#ifdef CONFIG_X86_64
     enum { lm_seg_none, lm_seg_fs, lm_seg_gs } lm_ovr = lm_seg_none;
+#else
+    enum { lm_seg_none, lm_seg_fs, lm_seg_gs } __attribute__((__unused__)) lm_ovr = lm_seg_none;
+#endif
     int rc;
     unsigned int port, i, data_sel, ar, data, bpmatch = 0;
     unsigned int op_bytes, op_default, ad_bytes, ad_default, opsize_prefix= 0;