Subject: Re: Adding /proc/swaps to linux compat code
To: None <tech-kern@NetBSD.org>
From: Christian Biere <christianbiere@gmx.de>
List: tech-kern
Date: 02/01/2007 00:11:36
Arnaud Lacombe wrote:
> A first patch is available here:
> http://www.sigfpe.info/netbsd/proc_swaps.diff

 * You should check the return value of snprintf() with "<= 0" instead of "== 0".
   At least when remaining reached zero, snprintf() will return -1 and not 0.

 * totallen and remaining are completely redundant. Use the difference to an
   "endptr" instead.

 * The short-cut nswap is unnecessary and doesn't really pay off here.

 * You should return some error code instead of zero if the buffer is really to
   short.

 * This is clearer:
   struct swapent *sep0;
   const struct swapent *sep;

 * Use M_ZERO instead of memset().

-- 
Christian