Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/net knf, no functional change.
details: https://anonhg.NetBSD.org/src/rev/afc9cc5428a6
branches: trunk
changeset: 333983:afc9cc5428a6
user: christos <christos%NetBSD.org@localhost>
date: Mon Nov 24 15:43:21 2014 +0000
description:
knf, no functional change.
diffstat:
lib/libc/net/base64.c | 69 +++++++++++++++++++++++++-------------------------
1 files changed, 34 insertions(+), 35 deletions(-)
diffs (191 lines):
diff -r 4e8d870c565c -r afc9cc5428a6 lib/libc/net/base64.c
--- a/lib/libc/net/base64.c Mon Nov 24 15:41:18 2014 +0000
+++ b/lib/libc/net/base64.c Mon Nov 24 15:43:21 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: base64.c,v 1.15 2014/11/24 15:41:18 christos Exp $ */
+/* $NetBSD: base64.c,v 1.16 2014/11/24 15:43:21 christos Exp $ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -47,7 +47,7 @@
#if 0
static const char rcsid[] = "Id: base64.c,v 1.4 2005/04/27 04:56:34 sra Exp";
#else
-__RCSID("$NetBSD: base64.c,v 1.15 2014/11/24 15:41:18 christos Exp $");
+__RCSID("$NetBSD: base64.c,v 1.16 2014/11/24 15:43:21 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -155,11 +155,11 @@
input[2] = *src++;
srclength -= 3;
- output[0] = (u_int32_t)input[0] >> 2;
- output[1] = ((u_int32_t)(input[0] & 0x03) << 4) +
- ((u_int32_t)input[1] >> 4);
- output[2] = ((u_int32_t)(input[1] & 0x0f) << 2) +
- ((u_int32_t)input[2] >> 6);
+ output[0] = (uint32_t)input[0] >> 2;
+ output[1] = ((uint32_t)(input[0] & 0x03) << 4) +
+ ((uint32_t)input[1] >> 4);
+ output[2] = ((uint32_t)(input[1] & 0x0f) << 2) +
+ ((uint32_t)input[2] >> 6);
output[3] = input[2] & 0x3f;
Assert(output[0] < 64);
Assert(output[1] < 64);
@@ -167,7 +167,7 @@
Assert(output[3] < 64);
if (datalength + 4 > targsize)
- return (-1);
+ return -1;
target[datalength++] = Base64[output[0]];
target[datalength++] = Base64[output[1]];
target[datalength++] = Base64[output[2]];
@@ -181,17 +181,17 @@
for (i = 0; i < srclength; i++)
input[i] = *src++;
- output[0] = (u_int32_t)input[0] >> 2;
- output[1] = ((u_int32_t)(input[0] & 0x03) << 4) +
- ((u_int32_t)input[1] >> 4);
- output[2] = ((u_int32_t)(input[1] & 0x0f) << 2) +
- ((u_int32_t)input[2] >> 6);
+ output[0] = (uint32_t)input[0] >> 2;
+ output[1] = ((uint32_t)(input[0] & 0x03) << 4) +
+ ((uint32_t)input[1] >> 4);
+ output[2] = ((uint32_t)(input[1] & 0x0f) << 2) +
+ ((uint32_t)input[2] >> 6);
Assert(output[0] < 64);
Assert(output[1] < 64);
Assert(output[2] < 64);
if (datalength + 4 > targsize)
- return (-1);
+ return -1;
target[datalength++] = Base64[output[0]];
target[datalength++] = Base64[output[1]];
if (srclength == 1U)
@@ -201,7 +201,7 @@
target[datalength++] = Pad64;
}
if (datalength >= targsize)
- return (-1);
+ return -1;
target[datalength] = '\0'; /*%< Returned value doesn't count \\0. */
_DIAGASSERT(__type_fit(int, datalength));
return (int)datalength;
@@ -235,44 +235,44 @@
break;
pos = strchr(Base64, ch);
- if (pos == 0) /*%< A non-base64 character. */
- return (-1);
+ if (pos == NULL) /*%< A non-base64 character. */
+ return -1;
switch (state) {
case 0:
if (target) {
- if ((size_t)tarindex >= targsize)
- return (-1);
+ if (tarindex >= targsize)
+ return -1;
target[tarindex] = (u_char)(pos - Base64) << 2;
}
state = 1;
break;
case 1:
if (target) {
- if ((size_t)tarindex >= targsize)
- return (-1);
+ if (tarindex >= targsize)
+ return -1;
target[tarindex] |=
- (u_int32_t)(pos - Base64) >> 4;
+ (uint32_t)(pos - Base64) >> 4;
nextbyte = (u_char)((pos - Base64) & 0x0f) << 4;
if (tarindex + 1 < targsize)
target[tarindex + 1] = nextbyte;
else if (nextbyte)
- return (-1);
+ return -1;
}
tarindex++;
state = 2;
break;
case 2:
if (target) {
- if ((size_t)tarindex >= targsize)
- return (-1);
+ if (tarindex >= targsize)
+ return -1;
target[tarindex] |=
- (u_int32_t)(pos - Base64) >> 2;
+ (uint32_t)(pos - Base64) >> 2;
nextbyte = (u_char)((pos - Base64) & 0x03) << 6;
if (tarindex + 1 < targsize)
target[tarindex + 1] = nextbyte;
else if (nextbyte)
- return (-1);
+ return -1;
}
tarindex++;
state = 3;
@@ -280,9 +280,8 @@
case 3:
if (target) {
if ((size_t)tarindex >= targsize)
- return (-1);
- target[tarindex] |=
- (unsigned char)(pos - Base64);
+ return -1;
+ target[tarindex] |= (u_char)(pos - Base64);
}
tarindex++;
state = 0;
@@ -302,7 +301,7 @@
switch (state) {
case 0: /*%< Invalid = in first position */
case 1: /*%< Invalid = in second position */
- return (-1);
+ return -1;
case 2: /*%< Valid, means one byte of info */
/* Skip any number of spaces. */
@@ -311,7 +310,7 @@
break;
/* Make sure there is another trailing = sign. */
if (ch != Pad64)
- return (-1);
+ return -1;
ch = *src++; /*%< Skip the = */
/* Fall through to "single trailing =" case. */
/* FALLTHROUGH */
@@ -323,7 +322,7 @@
*/
for (; ch != '\0'; ch = (u_char) *src++)
if (!isspace(ch))
- return (-1);
+ return -1;
/*
* Now make sure for cases 2 and 3 that the "extra"
@@ -333,7 +332,7 @@
*/
if (target && tarindex < targsize &&
target[tarindex] != 0)
- return (-1);
+ return -1;
}
} else {
/*
@@ -341,7 +340,7 @@
* have no partial bytes lying around.
*/
if (state != 0)
- return (-1);
+ return -1;
}
_DIAGASSERT(__type_fit(int, tarindex));
Home |
Main Index |
Thread Index |
Old Index