summaryrefslogtreecommitdiffstats
path: root/sys/dev/raidframe/rf_utils.c
diff options
context:
space:
mode:
authortdeval <tdeval@openbsd.org>2002-12-16 07:01:02 +0000
committertdeval <tdeval@openbsd.org>2002-12-16 07:01:02 +0000
commit02be053e1228ba4c0a567701ded8cec05be5df63 (patch)
tree4810bcbe357aeb65b2f475f98fd7ce2f26089128 /sys/dev/raidframe/rf_utils.c
parenttypo; from Tor Houghton <torh@bogus.net> (diff)
downloadwireguard-openbsd-02be053e1228ba4c0a567701ded8cec05be5df63.tar.xz
wireguard-openbsd-02be053e1228ba4c0a567701ded8cec05be5df63.zip
Major KNF. Incentive from Tedu
Diffstat (limited to 'sys/dev/raidframe/rf_utils.c')
-rw-r--r--sys/dev/raidframe/rf_utils.c98
1 files changed, 47 insertions, 51 deletions
diff --git a/sys/dev/raidframe/rf_utils.c b/sys/dev/raidframe/rf_utils.c
index 2b5a99cbebf..c136b0fe7fa 100644
--- a/sys/dev/raidframe/rf_utils.c
+++ b/sys/dev/raidframe/rf_utils.c
@@ -1,5 +1,6 @@
-/* $OpenBSD: rf_utils.c,v 1.4 2000/01/11 18:02:23 peter Exp $ */
+/* $OpenBSD: rf_utils.c,v 1.5 2002/12/16 07:01:05 tdeval Exp $ */
/* $NetBSD: rf_utils.c,v 1.5 2000/01/07 03:41:03 oster Exp $ */
+
/*
* Copyright (c) 1995 Carnegie-Mellon University.
* All rights reserved.
@@ -27,11 +28,11 @@
* rights to redistribute these changes.
*/
-/****************************************
+/******************************************
*
- * rf_utils.c -- various support routines
+ * rf_utils.c -- Various support routines.
*
- ****************************************/
+ ******************************************/
#include "rf_threadstuff.h"
@@ -43,28 +44,24 @@
#include "rf_alloclist.h"
#include "rf_general.h"
-/* creates & zeros 2-d array with b rows and k columns (MCH) */
+/* Creates & zeros 2-d array with b rows and k columns. (MCH) */
RF_RowCol_t **
-rf_make_2d_array(b, k, allocList)
- int b;
- int k;
- RF_AllocListElem_t *allocList;
+rf_make_2d_array(int b, int k, RF_AllocListElem_t *allocList)
{
RF_RowCol_t **retval, i;
- RF_MallocAndAdd(retval, b * sizeof(RF_RowCol_t *), (RF_RowCol_t **), allocList);
+ RF_MallocAndAdd(retval, b * sizeof(RF_RowCol_t *), (RF_RowCol_t **),
+ allocList);
for (i = 0; i < b; i++) {
- RF_MallocAndAdd(retval[i], k * sizeof(RF_RowCol_t), (RF_RowCol_t *), allocList);
- (void) bzero((char *) retval[i], k * sizeof(RF_RowCol_t));
+ RF_MallocAndAdd(retval[i], k * sizeof(RF_RowCol_t),
+ (RF_RowCol_t *), allocList);
+ bzero((char *) retval[i], k * sizeof(RF_RowCol_t));
}
return (retval);
}
-void
-rf_free_2d_array(a, b, k)
- RF_RowCol_t **a;
- int b;
- int k;
+void
+rf_free_2d_array(RF_RowCol_t **a, int b, int k)
{
RF_RowCol_t i;
@@ -73,36 +70,32 @@ rf_free_2d_array(a, b, k)
RF_Free(a, b * sizeof(RF_RowCol_t));
}
-
-/* creates & zeros a 1-d array with c columns */
+/* Creates & zeroes a 1-d array with c columns. */
RF_RowCol_t *
-rf_make_1d_array(c, allocList)
- int c;
- RF_AllocListElem_t *allocList;
+rf_make_1d_array(int c, RF_AllocListElem_t *allocList)
{
RF_RowCol_t *retval;
- RF_MallocAndAdd(retval, c * sizeof(RF_RowCol_t), (RF_RowCol_t *), allocList);
- (void) bzero((char *) retval, c * sizeof(RF_RowCol_t));
+ RF_MallocAndAdd(retval, c * sizeof(RF_RowCol_t), (RF_RowCol_t *),
+ allocList);
+ bzero((char *) retval, c * sizeof(RF_RowCol_t));
return (retval);
}
-void
-rf_free_1d_array(a, n)
- RF_RowCol_t *a;
- int n;
+void
+rf_free_1d_array(RF_RowCol_t *a, int n)
{
RF_Free(a, n * sizeof(RF_RowCol_t));
}
-/* Euclid's algorithm: finds and returns the greatest common divisor
- * between a and b. (MCH)
+
+/*
+ * Euclid's algorithm: Finds and returns the greatest common divisor
+ * between a and b. (MCH)
*/
-int
-rf_gcd(m, n)
- int m;
- int n;
+int
+rf_gcd(int m, int n)
{
- int t;
+ int t;
while (m > 0) {
t = n % m;
@@ -111,21 +104,25 @@ rf_gcd(m, n)
}
return (n);
}
-/* these convert between text and integer. Apparently the regular C macros
- * for doing this are not available in the kernel
- */
-#define ISDIGIT(x) ( (x) >= '0' && (x) <= '9' )
-#define ISHEXCHAR(x) ( ((x) >= 'a' && (x) <= 'f') || ((x) >= 'A' && (x) <= 'F') )
-#define ISHEX(x) ( ISDIGIT(x) || ISHEXCHAR(x) )
-#define HC2INT(x) ( ((x) >= 'a' && (x) <= 'f') ? (x) - 'a' + 10 : \
- ( ((x) >= 'A' && (x) <= 'F') ? (x) - 'A' + 10 : (x - '0') ) )
+/*
+ * These convert between text and integer. Apparently the regular C macros
+ * for doing this are not available in the kernel.
+ */
-int
-rf_atoi(p)
- char *p;
+#define ISDIGIT(x) ((x) >= '0' && (x) <= '9')
+#define ISHEXCHAR(x) (((x) >= 'a' && (x) <= 'f') || \
+ ((x) >= 'A' && (x) <= 'F'))
+#define ISHEX(x) (ISDIGIT(x) || ISHEXCHAR(x))
+#define HC2INT(x) (((x) >= 'a' && (x) <= 'f') ? \
+ (x) - 'a' + 10 : \
+ (((x) >= 'A' && (x) <= 'F') ? \
+ (x) - 'A' + 10 : (x - '0')))
+
+int
+rf_atoi(char *p)
{
- int val = 0, negate = 0;
+ int val = 0, negate = 0;
if (*p == '-') {
negate = 1;
@@ -136,11 +133,10 @@ rf_atoi(p)
return ((negate) ? -val : val);
}
-int
-rf_htoi(p)
- char *p;
+int
+rf_htoi(char *p)
{
- int val = 0;
+ int val = 0;
for (; ISHEXCHAR(*p); p++)
val = 16 * val + HC2INT(*p);
return (val);