DragonFly BSD
DragonFly submit List (threaded) for 2005-05
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: cleanup patches


From: Haakon Schad Bergsaker <hakonsb@xxxxxxxxxxx>
Date: Thu, 12 May 2005 20:46:45 +0200 (CEST)

Hey, here I have written down some comments on the patch. Hope this
helps:)

General:
- Added appropriate system headers. This includes removing a bunch of
  math function externs from trek.h and instead include math.h in the
  files that need it.
- Added/moved function prototypes and variable externs to trek.h, except
  those for getpar.c, which were added/moved to getpar.h. Also added
  static prototypes where appropriate.
- Changed to style(9) function declarations.
- Changed preprocessor directives to match style(9), e.g.
      "#       define     foo    0" became
      "#define foo	0"
- Enclosed fields in array constants with curly brackets.
- Changed "return(foo());" to "foo(); return;" when foo or the current
  function was of type void. As most of trek's functions was defined
  without specifying return type, they probably defaulted to int, but many
  of them never returned values. Those I defined as void.
- Changed "char *" to "const char *" where appropriate.
- Removed superfluous return statements at the end of void functions.
- Removed (void) casts of non-void function calls.
- Enclosed some nested blocks in { } as recommended by gcc.
- Removed some reimplementations of standard libc functions, see
  utility.c comment.
- Added /* NOTREACHED */ comment a few places.
- Changed occurences of sprintf to snprintf.

Additional file-specific comments:
- cgetc.c: Not needed anymore, replaced the wrapper function cgetc with
  the getchar libc function.
- checkcond.c: Removed unused variables i,j.
- computer.c: Removed unused variable numout.
- dumpme.c: Changed increase(+=) to assignment(=) as the variable x was
  uninitialized.
- dumpssradio.c: The first parameter to systemname was not at all of
  correct type. I looked into OpenBSD's repository, and changed it in the
  same way as they had, which makes a lot more sense.
- events.c: Changed warp to _warp as there is already a function by that
  name. Initialized the variables j and ev. Corrected number of arguments
  to snova(). Changed to use a pointer p instead of an integer i to point
  at Etc.snapshot.
- getpar.h: Changed from (int *)() to (void *)() in struct cvntab since
  the return value of a call is always ignored.
- help.c: Initialized l.
- kill.c: Removed unused j.
- main.c: Defined USE_OLD_TTY to make TIOCGETP available, and changed the
  deprecated use of gtty in main to the right ioctl. Maybe this shouldn't
  be here anymore at all?
- move.c: Initialized variables ix and iy in function move.
- phaser.c: Initilized variable extra in function phaser.
- schedule.c: Added a dummy return statement after a syserr call in the
  schedule function.
- setup.c: Removed unused varible fd.
- shield.c: Removed unused variable c.
- snova.c: Moved assignment of variable iy so it will always be
  initialized. Changed killb call to correct number of arguments.
- srscan.c: Moved assignment of variable q.
- trek.h: Changed some struct fields from char to unsigned char, since
  they are used as array indices and never become negative. (gcc
  complaining).
- utility.c: Removed bmove, sequal, concat and length functions, to be
  replaced by libc's memmove, strcmp, strcpy+strcat and strlen. Also
  updated the syserr function to use va_list/vprintf.

-- 
Haakon Schad Bergsaker

On Tue, 11 Jan 2005, Liam J. Foy wrote:

> On Tue(03)/May/05 - , Haakon Schad Bergsaker wrote:
> > Hi,
> >
> > Some time ago I sent cleanup patches for games/trek and usr.bin/ktrace to
> > this list, but I haven't got any feedback. I was just wondering if nobody
> > have had time to look at them, or they did, but thought they were crap:)
> >
> > --
> > Haakon Schad Bergsaker
>
> Hey!
>
> In the trek patch, can you state exactly what you have done. It's a pretty
> large patch. For example, ANSI, remove variable etc etc. It helps alot when
> reading it. =)
>
> --
> 		- Liam J. Foy
> 		liamfoy@xxxxxxxxxxxxx
> 		http://www.bsd-systems.co.uk
>



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]