diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c
index 30430a2f58a..c46d6a5e88d 100644
--- a/opcodes/i386-gen.c
+++ b/opcodes/i386-gen.c
@@ -1841,7 +1841,7 @@ process_i386_opcodes (FILE *table)
 	  fprintf (fp, "#define MN_%s ", str);
 	  free (str);
 	  str = mkident (next);
-	  fprintf (fp, "(MN_%s + %u)\n", str, l1 - l);
+	  fprintf (fp, "(MN_%s + %zu)\n", str, l1 - l);
 	}
       else
 	{
diff --git a/opcodes/ia64-gen.c b/opcodes/ia64-gen.c
index ad91e77248e..0118dd78757 100644
--- a/opcodes/ia64-gen.c
+++ b/opcodes/ia64-gen.c
@@ -607,7 +607,8 @@ load_insn_classes (void)
     fail (_("can't find ia64-ic.tbl for reading\n"));
 
   /* Discard first line.  */
-  fgets (buf, sizeof(buf), fp);
+  if (fgets (buf, sizeof(buf), fp) == NULL)
+    return;
 
   while (!feof (fp))
     {
@@ -808,7 +809,8 @@ load_depfile (const char *filename, enum ia64_dependency_mode mode)
   if (fp == NULL)
     fail (_("can't find %s for reading\n"), filename);
 
-  fgets (buf, sizeof(buf), fp);
+  if (fgets (buf, sizeof(buf), fp) == NULL)
+    return;
   while (!feof (fp))
     {
       char *name, *tmp;
