]> Devi Nivas Git - cs3210-lab0.git/commitdiff
delete unnecessary #include lines
authorrsc <rsc>
Mon, 27 Aug 2007 23:26:33 +0000 (23:26 +0000)
committerrsc <rsc>
Mon, 27 Aug 2007 23:26:33 +0000 (23:26 +0000)
27 files changed:
8253pit.c
bio.c
console.c
cuth [new file with mode: 0755]
exec.c
file.c
fs.c
ide.c
init.c
ioapic.c
kalloc.c
lapic.c
main.c
mkfs.c
mp.c
picirq.c
pipe.c
proc.c
sh.c
spinlock.c
string.c
syscall.c
sysfile.c
sysproc.c
trap.c
umalloc.c
zombie.c

index 12867fb2bc07037bd5c7df44ac58fb4632e8da1a..1d98dc1501feed88a3753fe11ff5f2dc776dcb99 100644 (file)
--- a/8253pit.c
+++ b/8253pit.c
@@ -1,7 +1,7 @@
 #include "types.h"
-#include "x86.h"
 #include "defs.h"
 #include "traps.h"
+#include "x86.h"
 
 // Register definitions for the Intel
 // 8253/8254/82C54 Programmable Interval Timer (PIT).
diff --git a/bio.c b/bio.c
index 5d09acf6c8901a4d593ffe6363acae34bae857ea..eba8e024ab3fa6af8147680f750d7d3da0a87b37 100644 (file)
--- a/bio.c
+++ b/bio.c
 //     and needs to be written to disk.
 
 #include "types.h"
-#include "param.h"
-#include "x86.h"
-#include "mmu.h"
-#include "proc.h"
 #include "defs.h"
+#include "param.h"
 #include "spinlock.h"
 #include "buf.h"
 
index b1518c087086d270b30970b4001cd6a1f914445b..3e45e3ef94a53befbe969b4abc5934c32b436c76 100644 (file)
--- a/console.c
+++ b/console.c
@@ -1,12 +1,12 @@
 #include "types.h"
-#include "x86.h"
-#include "traps.h"
 #include "defs.h"
+#include "param.h"
+#include "traps.h"
 #include "spinlock.h"
 #include "dev.h"
-#include "param.h"
 #include "mmu.h"
 #include "proc.h"
+#include "x86.h"
 #include "kbd.h"
 
 #define CRTPORT 0x3d4
diff --git a/cuth b/cuth
new file mode 100755 (executable)
index 0000000..cce8c0c
--- /dev/null
+++ b/cuth
@@ -0,0 +1,48 @@
+#!/usr/bin/perl
+
+$| = 1;
+
+sub writefile($@){
+       my ($file, @lines) = @_;
+       
+       sleep(1);
+       open(F, ">$file") || die "open >$file: $!";
+       print F @lines;
+       close(F);
+}
+
+# Cut out #include lines that don't contribute anything.
+for($i=0; $i<@ARGV; $i++){
+       $file = $ARGV[$i];
+       if(!open(F, $file)){
+               print STDERR "open $file: $!\n";
+               next;
+       }
+       @lines = <F>;
+       close(F);
+       
+       $obj = "$file.o";
+       $obj =~ s/\.c\.o$/.o/;
+       system("touch $file");
+
+       if(system("make CC='gcc -Werror' $obj >/dev/null 2>\&1") != 0){
+               print STDERR "make $obj failed: $rv\n";
+               next;
+       }
+
+       system("cp $file =$file");
+       for($j=@lines-1; $j>=0; $j--){
+               if($lines[$j] =~ /^#include/){
+                       $old = $lines[$j];
+                       $lines[$j] = "/* CUT-H */\n";
+                       writefile($file, @lines);
+                       if(system("make CC='gcc -Werror' $obj >/dev/null 2>\&1") != 0){
+                               $lines[$j] = $old;
+                       }else{
+                               print STDERR "$file $old";
+                       }
+               }
+       }
+       writefile($file, grep {!/CUT-H/} @lines);
+       system("rm =$file");
+}
diff --git a/exec.c b/exec.c
index 9f06605e5ae6114780474b5851eb407fd1ed0e74..5905c16bfb2ac6890a4fb5d27c20681e360b18f7 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -4,7 +4,6 @@
 #include "proc.h"
 #include "defs.h"
 #include "x86.h"
-#include "fs.h"
 #include "elf.h"
 
 int
diff --git a/file.c b/file.c
index 273ba2a8675485dcc3d72ca90e4db09c5e410882..7f17b659d4ba565d3083318237fcf5a1913010b9 100644 (file)
--- a/file.c
+++ b/file.c
@@ -1,15 +1,9 @@
 #include "types.h"
-#include "stat.h"
-#include "param.h"
-#include "x86.h"
-#include "mmu.h"
-#include "proc.h"
 #include "defs.h"
+#include "param.h"
 #include "file.h"
 #include "spinlock.h"
 #include "dev.h"
-#include "fs.h"
-#include "fsvar.h"
 
 struct devsw devsw[NDEV];
 struct spinlock file_table_lock;
diff --git a/fs.c b/fs.c
index fb82f91592987b5dfdad9ebf0ec2ce35cc87ba0c..e92ffdad3a12aab3f86eccac60776790c5ead5c7 100644 (file)
--- a/fs.c
+++ b/fs.c
 // are in sysfile.c.
 
 #include "types.h"
-#include "stat.h"
+#include "defs.h"
 #include "param.h"
-#include "x86.h"
+#include "stat.h"
 #include "mmu.h"
 #include "proc.h"
-#include "defs.h"
 #include "spinlock.h"
 #include "buf.h"
 #include "fs.h"
diff --git a/ide.c b/ide.c
index 092b8ce874d02becc6326ac9c0fb8654fe34c77d..aa8fe2958edda49e2d82b4faf9ddfe727f8afd01 100644 (file)
--- a/ide.c
+++ b/ide.c
@@ -1,10 +1,10 @@
 // Simple PIO-based (non-DMA) IDE driver code.
 
 #include "types.h"
+#include "defs.h"
 #include "param.h"
 #include "mmu.h"
 #include "proc.h"
-#include "defs.h"
 #include "x86.h"
 #include "traps.h"
 #include "spinlock.h"
diff --git a/init.c b/init.c
index e873f3b071c0d9b8ff5eac0f179c0d6a67fef8ff..d3e118287c1906c3219b0f265ab54c8356ce0237 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1,7 +1,6 @@
 #include "types.h"
 #include "stat.h"
 #include "user.h"
-#include "fs.h"
 #include "fcntl.h"
 
 // init: The initial user-level program
index a009ca891848f80bf284f0b842d76e2b7f496041..8da31512213cd00767d9d74b6ddb287fed3247c5 100644 (file)
--- a/ioapic.c
+++ b/ioapic.c
@@ -2,9 +2,7 @@
 // http://www.intel.com/design/chipsets/datashts/29056601.pdf
 
 #include "types.h"
-#include "mp.h"
 #include "defs.h"
-#include "x86.h"
 #include "traps.h"
 
 #define IOAPIC  0xFEC00000   // Default physical address of IO APIC
index eb782129d1e372c91212e0ff163e3ba9954535e2..e0b9765c849e4e2d6867fa104aaa7aee44531cb8 100644 (file)
--- a/kalloc.c
+++ b/kalloc.c
@@ -5,12 +5,9 @@
 // One reason the page size is 4k is that the x86 segment size
 // granularity is 4k.
 
-#include "param.h"
 #include "types.h"
 #include "defs.h"
 #include "param.h"
-#include "mmu.h"
-#include "proc.h"
 #include "spinlock.h"
 
 struct spinlock kalloc_lock;
diff --git a/lapic.c b/lapic.c
index 6afc3b8ee0539c69ca101d439817170d757b8aa7..5df4f8636d6937ad8425fc65524cd1b086c854e9 100644 (file)
--- a/lapic.c
+++ b/lapic.c
@@ -2,12 +2,7 @@
 // See Chapter 8 & Appendix C of Intel processor manual volume 3.
 
 #include "types.h"
-#include "defs.h"
-#include "param.h"
-#include "x86.h"
 #include "traps.h"
-#include "mmu.h"
-#include "proc.h"
 
 // Local APIC registers, divided by 4 for use as uint[] indices.
 #define ID      (0x0020/4)   // ID
diff --git a/main.c b/main.c
index a8b3f623895d774968d911bd7f65419163fa6d11..570c164e980cf1ca8e32e45db5a8311c726304ac 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,23 +1,15 @@
 #include "types.h"
+#include "defs.h"
 #include "param.h"
 #include "mmu.h"
 #include "proc.h"
-#include "defs.h"
 #include "x86.h"
-#include "traps.h"
-#include "syscall.h"
-#include "elf.h"
-#include "param.h"
-#include "spinlock.h"
 
 extern char edata[], end[];
 
 void bootothers(void);
 
 // Bootstrap processor starts running C code here.
-// This is called main0 not main so that it can have
-// a void return type.  Gcc can't handle functions named
-// main that don't return int.  Really.
 void
 main0(void)
 {
@@ -39,7 +31,7 @@ main0(void)
   asm volatile("movl %0, %%ebp" : : "r" (cpus[bcpu].mpstack+MPSTACK));
 
   lapic_init(bcpu);
-  cprintf("\\ncpu%d: starting xv6\\n\\n", cpu());
+  cprintf("\ncpu%d: starting xv6\n\n", cpu());
 
   pinit();         // process table
   binit();         // buffer cache
@@ -69,7 +61,7 @@ main0(void)
 void
 mpmain(void)
 {
-  cprintf("cpu%d: starting\\n", cpu());
+  cprintf("cpu%d: starting\n", cpu());
   idtinit();
   lapic_init(cpu());
   setupsegs(0);
diff --git a/mkfs.c b/mkfs.c
index b367f617a52c5a1fbbd3343baba2f76dd1a9c106..32bf4e77ff72047e4a095eb98d2baf91d238e296 100644 (file)
--- a/mkfs.c
+++ b/mkfs.c
@@ -5,7 +5,6 @@
 #include <fcntl.h>
 #include <assert.h>
 #include "types.h"
-#include "param.h"
 #include "fs.h"
 
 int nblocks = 995;
@@ -55,7 +54,7 @@ int
 main(int argc, char *argv[])
 {
   int i, cc, fd;
-  uint bn, rootino, inum, off;
+  uint rootino, inum, off;
   struct dirent de;
   char buf[512];
   struct dinode din;
diff --git a/mp.c b/mp.c
index edd85df755a1b0a3796faa7f5937496d15d4b0be..563a401c029179d8ccf5a2615b27a7a3006e1095 100644 (file)
--- a/mp.c
+++ b/mp.c
@@ -1,11 +1,10 @@
 // http://developer.intel.com/design/pentium/datashts/24201606.pdf
 
 #include "types.h"
-#include "mp.h"
 #include "defs.h"
 #include "param.h"
+#include "mp.h"
 #include "x86.h"
-#include "traps.h"
 #include "mmu.h"
 #include "proc.h"
 
index b7d0116d12ae1505e7d58efa81b5f150dda8146d..7c5f71307dbb3f4db8e2d183ecf18041cdcbe025 100644 (file)
--- a/picirq.c
+++ b/picirq.c
@@ -1,7 +1,6 @@
 #include "types.h"
 #include "x86.h"
 #include "traps.h"
-#include "defs.h"
 
 // I/O Addresses of the two 8259A programmable interrupt controllers
 #define IO_PIC1         0x20    // Master (IRQs 0-7)
diff --git a/pipe.c b/pipe.c
index cd27cbf896aa2f56cb4aca68425789ae9b818426..83afb352e7a7ff098e79c2caecff2ee8e69ff14d 100644 (file)
--- a/pipe.c
+++ b/pipe.c
@@ -1,9 +1,8 @@
 #include "types.h"
+#include "defs.h"
 #include "param.h"
-#include "x86.h"
 #include "mmu.h"
 #include "proc.h"
-#include "defs.h"
 #include "file.h"
 #include "spinlock.h"
 
diff --git a/proc.c b/proc.c
index 776c8b41fe85ef59e6f94a09db7d4b1a568cbbe6..eb7d1f8107fcb33f88a4bd17d1204e541ba2a397 100644 (file)
--- a/proc.c
+++ b/proc.c
@@ -1,10 +1,9 @@
 #include "types.h"
+#include "defs.h"
+#include "param.h"
 #include "mmu.h"
 #include "x86.h"
-#include "param.h"
-#include "file.h"
 #include "proc.h"
-#include "defs.h"
 #include "spinlock.h"
 
 struct spinlock proc_table_lock;
diff --git a/sh.c b/sh.c
index 1b517ef05c643035daf14ee91fe6fb048848032c..205b4456b0c83647fac722b25bdb4d666d2a22c3 100644 (file)
--- a/sh.c
+++ b/sh.c
@@ -1,7 +1,6 @@
 #include "types.h"
 #include "stat.h"
 #include "user.h"
-#include "fs.h"
 #include "fcntl.h"
 
 #define BUFSIZ  512
index af0c2e9a1c21993e1e61f0197eee849e6495a100..236235c9ff0b61a529b0f555cdb78b9ce4f4ef4f 100644 (file)
@@ -2,9 +2,9 @@
 
 #include "types.h"
 #include "defs.h"
+#include "param.h"
 #include "x86.h"
 #include "mmu.h"
-#include "param.h"
 #include "proc.h"
 #include "spinlock.h"
 
index 2f9fc258affdc7d82a4a51727523d84c65f189f8..57202451bed2f6b860c092d58cc3682ab7ee240e 100644 (file)
--- a/string.c
+++ b/string.c
@@ -1,5 +1,4 @@
 #include "types.h"
-#include "defs.h"
 
 void*
 memset(void *dst, int c, uint n)
index 9fed725d543fb50d27eb523d7000aef4ba5214f9..bc6c316010c4d70010c57dc1d44029e15ce83d8a 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -1,19 +1,10 @@
 #include "types.h"
-#include "stat.h"
+#include "defs.h"
 #include "param.h"
 #include "mmu.h"
 #include "proc.h"
-#include "defs.h"
 #include "x86.h"
-#include "traps.h"
 #include "syscall.h"
-#include "spinlock.h"
-#include "buf.h"
-#include "fs.h"
-#include "fsvar.h"
-#include "elf.h"
-#include "file.h"
-#include "fcntl.h"
 
 // User code makes a system call with INT T_SYSCALL.
 // System call number in %eax.
index 105fb48e6faec973ea6f2467eebfdab90ec32ca5..71b8785a5a5d2290b3361ba96f14f6e991e6052f 100644 (file)
--- a/sysfile.c
+++ b/sysfile.c
@@ -1,14 +1,9 @@
 #include "types.h"
-#include "stat.h"
+#include "defs.h"
 #include "param.h"
+#include "stat.h"
 #include "mmu.h"
 #include "proc.h"
-#include "defs.h"
-#include "x86.h"
-#include "traps.h"
-#include "syscall.h"
-#include "spinlock.h"
-#include "buf.h"
 #include "fs.h"
 #include "fsvar.h"
 #include "file.h"
index 48fbe373dc68561897c6a9277127b79b0769de34..b7692164fdceefffee3644858a46babb821d4aa8 100644 (file)
--- a/sysproc.c
+++ b/sysproc.c
@@ -1,19 +1,8 @@
 #include "types.h"
-#include "stat.h"
+#include "defs.h"
 #include "param.h"
 #include "mmu.h"
 #include "proc.h"
-#include "defs.h"
-#include "x86.h"
-#include "traps.h"
-#include "syscall.h"
-#include "spinlock.h"
-#include "buf.h"
-#include "fs.h"
-#include "fsvar.h"
-#include "elf.h"
-#include "file.h"
-#include "fcntl.h"
 
 int
 sys_fork(void)
diff --git a/trap.c b/trap.c
index e045aeded07370e1daefa5d659d45b55992e7425..5955cfcb20ed17b5769f7acc900d47683d97a105 100644 (file)
--- a/trap.c
+++ b/trap.c
@@ -1,11 +1,10 @@
 #include "types.h"
+#include "defs.h"
 #include "param.h"
 #include "mmu.h"
 #include "proc.h"
-#include "defs.h"
 #include "x86.h"
 #include "traps.h"
-#include "syscall.h"
 #include "spinlock.h"
 
 // Interrupt descriptor table (shared by all CPUs).
index 30f970dbb29b0a2f5c19844271ae436b6519a9e9..401ee6a064656c570ffac29d8d4fa97604296b8d 100644 (file)
--- a/umalloc.c
+++ b/umalloc.c
@@ -3,8 +3,8 @@
 #include "user.h"
 #include "param.h"
 
-// Memory allocator by Kernighan and Ritchie, The C programming Language,
-// 2nd ed.  Section 8.7.
+// Memory allocator by Kernighan and Ritchie,
+// The C programming Language, 2nd ed.  Section 8.7.
 
 typedef long Align;
 
index 07ad7982419e1d743d42874467699a66c75c0ebf..077c02c886a8df2697f19e3cb05c92b990a2d30e 100644 (file)
--- a/zombie.c
+++ b/zombie.c
@@ -8,8 +8,6 @@
 int
 main(void)
 {
-  int i;
-
   if(fork() > 0)
     sleep(5);  // Let child exit before parent.
   exit();