summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2006-01-15 19:12:00 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2006-01-15 19:12:00 +0000
commit011a44c19e590a3fba2cadbccfc0c067c6d82339 (patch)
treea7a03872c6a1083fe3054179c343915d0da884e7 /usr.bin
parent706ffea399bee5559214bff24c14ea6c195b5d38 (diff)
delint wrt return values, including some missing BN return
values checks.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/dc/bcode.c56
-rw-r--r--usr.bin/dc/bcode.h4
-rw-r--r--usr.bin/dc/dc.c12
-rw-r--r--usr.bin/dc/inout.c52
-rw-r--r--usr.bin/dc/stack.c8
5 files changed, 64 insertions, 68 deletions
diff --git a/usr.bin/dc/bcode.c b/usr.bin/dc/bcode.c
index d09f3cd9dfb..20175d7507d 100644
--- a/usr.bin/dc/bcode.c
+++ b/usr.bin/dc/bcode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcode.c,v 1.30 2005/09/25 19:02:38 otto Exp $ */
+/* $OpenBSD: bcode.c,v 1.31 2006/01/15 19:11:59 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
@@ -17,7 +17,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: bcode.c,v 1.30 2005/09/25 19:02:38 otto Exp $";
+static const char rcsid[] = "$OpenBSD: bcode.c,v 1.31 2006/01/15 19:11:59 otto Exp $";
#endif /* not lint */
#include <ssl/ssl.h>
@@ -59,7 +59,7 @@ static struct bmachine bmachine;
static void sighandler(int);
static __inline int readch(void);
-static __inline int unreadch(void);
+static __inline void unreadch(void);
static __inline char *readline(void);
static __inline void src_free(void);
@@ -262,7 +262,7 @@ init_bmachine(bool extended_registers)
bmachine.obase = bmachine.ibase = 10;
BN_init(&zero);
bn_check(BN_zero(&zero));
- signal(SIGINT, sighandler);
+ (void)signal(SIGINT, sighandler);
}
/* Reset the things needed before processing a (new) file */
@@ -281,12 +281,12 @@ readch(void)
return src->vtable->readchar(src);
}
-static __inline int
+static __inline void
unreadch(void)
{
struct source *src = &bmachine.readstack[bmachine.readsp];
- return src->vtable->unreadchar(src);
+ src->vtable->unreadchar(src);
}
static __inline char *
@@ -312,8 +312,8 @@ pn(const char *str, const struct number *n)
char *p = BN_bn2dec(n->number);
if (p == NULL)
err(1, "BN_bn2dec failed");
- fputs(str, stderr);
- fprintf(stderr, " %s (%u)\n" , p, n->scale);
+ (void)fputs(str, stderr);
+ (void)fprintf(stderr, " %s (%u)\n" , p, n->scale);
OPENSSL_free(p);
}
@@ -323,8 +323,8 @@ pbn(const char *str, const BIGNUM *n)
char *p = BN_bn2dec(n);
if (p == NULL)
err(1, "BN_bn2dec failed");
- fputs(str, stderr);
- fprintf(stderr, " %s\n", p);
+ (void)fputs(str, stderr);
+ (void)fprintf(stderr, " %s\n", p);
OPENSSL_free(p);
}
@@ -355,7 +355,7 @@ scale_number(BIGNUM *n, int s)
if (s > 0)
bn_check(BN_mul_word(n, factors[abs_scale]));
else
- BN_div_word(n, factors[abs_scale]);
+ (void)BN_div_word(n, factors[abs_scale]);
} else {
BIGNUM *a, *p;
BN_CTX *ctx;
@@ -388,11 +388,11 @@ split_number(const struct number *n, BIGNUM *i, BIGNUM *f)
bn_checkp(BN_copy(i, n->number));
if (n->scale == 0 && f != NULL)
- BN_zero(f);
+ bn_check(BN_zero(f));
else if (n->scale < sizeof(factors)/sizeof(factors[0])) {
rem = BN_div_word(i, factors[n->scale]);
if (f != NULL)
- BN_set_word(f, rem);
+ bn_check(BN_set_word(f, rem));
} else {
BIGNUM *a, *p;
BN_CTX *ctx;
@@ -494,7 +494,7 @@ print_tos(void)
struct value *value = tos();
if (value != NULL) {
print_value(stdout, value, "", bmachine.obase);
- putchar('\n');
+ (void)putchar('\n');
}
else
warnx("stack empty");
@@ -512,11 +512,11 @@ pop_print(void)
case BCODE_NUMBER:
normalize(value->u.num, 0);
print_ascii(stdout, value->u.num);
- fflush(stdout);
+ (void)fflush(stdout);
break;
case BCODE_STRING:
- fputs(value->u.string, stdout);
- fflush(stdout);
+ (void)fputs(value->u.string, stdout);
+ (void)fflush(stdout);
break;
}
stack_free_value(value);
@@ -530,7 +530,7 @@ pop_printn(void)
if (value != NULL) {
print_value(stdout, value, "", bmachine.obase);
- fflush(stdout);
+ (void)fflush(stdout);
stack_free_value(value);
}
}
@@ -695,7 +695,7 @@ count_digits(const struct number *n)
i = 0;
while (!BN_is_zero(int_part->number)) {
- BN_div_word(int_part->number, 10);
+ (void)BN_div_word(int_part->number, 10);
i++;
}
free_number(int_part);
@@ -937,7 +937,7 @@ comment(void)
static void
bexec(char *line)
{
- system(line);
+ (void)system(line);
free(line);
}
@@ -1228,7 +1228,7 @@ bexp(void)
one = BN_new();
bn_checkp(one);
- BN_one(one);
+ bn_check(BN_one(one));
ctx = BN_CTX_new();
bn_checkp(ctx);
scale_number(one, r->scale + scale);
@@ -1607,9 +1607,9 @@ skip_until_mark(void)
case '<':
case '>':
case '=':
- readreg();
+ (void)readreg();
if (readch() == 'e')
- readreg();
+ (void)readreg();
else
unreadch();
break;
@@ -1621,9 +1621,9 @@ skip_until_mark(void)
case '<':
case '>':
case '=':
- readreg();
+ (void)readreg();
if (readch() == 'e')
- readreg();
+ (void)readreg();
else
unreadch();
break;
@@ -1727,10 +1727,10 @@ eval(void)
bmachine.interrupted = false;
}
#ifdef DEBUGGING
- fprintf(stderr, "# %c\n", ch);
+ (void)fprintf(stderr, "# %c\n", ch);
stack_print(stderr, &bmachine.stack, "* ",
bmachine.obase);
- fprintf(stderr, "%d =>\n", bmachine.readsp);
+ (void)fprintf(stderr, "%d =>\n", bmachine.readsp);
#endif
if (0 <= ch && ch < UCHAR_MAX)
@@ -1741,7 +1741,7 @@ eval(void)
#ifdef DEBUGGING
stack_print(stderr, &bmachine.stack, "* ",
bmachine.obase);
- fprintf(stderr, "%d ==\n", bmachine.readsp);
+ (void)fprintf(stderr, "%d ==\n", bmachine.readsp);
#endif
}
}
diff --git a/usr.bin/dc/bcode.h b/usr.bin/dc/bcode.h
index 4fc7ba6819a..87e917e5ff5 100644
--- a/usr.bin/dc/bcode.h
+++ b/usr.bin/dc/bcode.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcode.h,v 1.3 2003/12/01 09:13:24 otto Exp $ */
+/* $OpenBSD: bcode.h,v 1.4 2006/01/15 19:11:59 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
@@ -66,7 +66,7 @@ struct source;
struct vtable {
int (*readchar)(struct source *);
- int (*unreadchar)(struct source *);
+ void (*unreadchar)(struct source *);
char *(*readline)(struct source *);
void (*free)(struct source *);
};
diff --git a/usr.bin/dc/dc.c b/usr.bin/dc/dc.c
index 094c3f6ca1d..7f249a8576a 100644
--- a/usr.bin/dc/dc.c
+++ b/usr.bin/dc/dc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dc.c,v 1.6 2004/10/18 07:49:00 otto Exp $ */
+/* $OpenBSD: dc.c,v 1.7 2006/01/15 19:11:59 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
@@ -17,7 +17,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: dc.c,v 1.6 2004/10/18 07:49:00 otto Exp $";
+static const char rcsid[] = "$OpenBSD: dc.c,v 1.7 2006/01/15 19:11:59 otto Exp $";
#endif /* not lint */
#include <err.h>
@@ -34,7 +34,7 @@ extern char *__progname;
static __dead void
usage(void)
{
- fprintf(stderr, "usage: %s [-x] [-e expr] [file]\n", __progname);
+ (void)fprintf(stderr, "usage: %s [-x] [-e expr] [file]\n", __progname);
exit(1);
}
@@ -71,8 +71,8 @@ main(int argc, char *argv[])
argv += optind;
init_bmachine(extended_regs);
- setlinebuf(stdout);
- setlinebuf(stderr);
+ (void)setlinebuf(stdout);
+ (void)setlinebuf(stderr);
if (argc > 1)
usage();
@@ -91,7 +91,7 @@ main(int argc, char *argv[])
src_setstream(&src, file);
reset_bmachine(&src);
eval();
- fclose(file);
+ (void)fclose(file);
/*
* BSD and Solaris dc(1) continue with stdin after processing
* the file given as the argument. We follow GNU dc(1).
diff --git a/usr.bin/dc/inout.c b/usr.bin/dc/inout.c
index 1afbbd888c9..9518bce82f7 100644
--- a/usr.bin/dc/inout.c
+++ b/usr.bin/dc/inout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inout.c,v 1.13 2005/12/14 08:10:02 otto Exp $ */
+/* $OpenBSD: inout.c,v 1.14 2006/01/15 19:11:59 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
@@ -17,7 +17,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: inout.c,v 1.13 2005/12/14 08:10:02 otto Exp $";
+static const char rcsid[] = "$OpenBSD: inout.c,v 1.14 2006/01/15 19:11:59 otto Exp $";
#endif /* not lint */
#include <ssl/ssl.h>
@@ -33,11 +33,11 @@ static int lastchar;
static int charcount;
static int src_getcharstream(struct source *);
-static int src_ungetcharstream(struct source *);
+static void src_ungetcharstream(struct source *);
static char *src_getlinestream(struct source *);
static void src_freestream(struct source *);
static int src_getcharstring(struct source *);
-static int src_ungetcharstring(struct source *);
+static void src_ungetcharstring(struct source *);
static char *src_getlinestring(struct source *);
static void src_freestring(struct source *);
static void flushwrap(FILE *);
@@ -80,12 +80,13 @@ src_getcharstream(struct source *src)
return src->lastchar = getc(src->u.stream);
}
-static int
+static void
src_ungetcharstream(struct source *src)
{
- return ungetc(src->lastchar, src->u.stream);
+ (void)ungetc(src->lastchar, src->u.stream);
}
+/* ARGSUSED */
static void
src_freestream(struct source *src)
{
@@ -113,18 +114,13 @@ src_getcharstring(struct source *src)
}
}
-static int
+static void
src_ungetcharstring(struct source *src)
{
- int ch;
-
if (src->u.string.pos > 0) {
if (src->lastchar != '\0')
--src->u.string.pos;
- ch = src->u.string.buf[src->u.string.pos];
- return ch == '\0' ? EOF : ch;
- } else
- return EOF;
+ }
}
static char *
@@ -156,7 +152,7 @@ static void
flushwrap(FILE *f)
{
if (lastchar != -1)
- putc(lastchar, f);
+ (void)putc(lastchar, f);
}
static void
@@ -164,11 +160,11 @@ putcharwrap(FILE *f, int ch)
{
if (charcount >= MAX_CHARS_PER_LINE) {
charcount = 0;
- fputs("\\\n", f);
+ (void)fputs("\\\n", f);
}
if (lastchar != -1) {
charcount++;
- putc(lastchar, f);
+ (void)putc(lastchar, f);
}
lastchar = ch;
}
@@ -179,7 +175,7 @@ printwrap(FILE *f, const char *p)
char buf[12];
char *q = buf;
- strlcpy(buf, p, sizeof(buf));
+ (void)strlcpy(buf, p, sizeof(buf));
while (*q)
putcharwrap(f, *q++);
}
@@ -229,7 +225,7 @@ readnumber(struct source *src, u_int base)
if (base != 10) {
scale_number(n->number, n->scale);
for (i = 0; i < n->scale; i++)
- BN_div_word(n->number, base);
+ (void)BN_div_word(n->number, base);
}
if (sign)
negate(n);
@@ -341,11 +337,11 @@ printnumber(FILE *f, const struct number *b, u_int base)
putcharwrap(f, '.');
num_base = new_number();
- BN_set_word(num_base->number, base);
+ bn_check(BN_set_word(num_base->number, base));
BN_init(&mult);
- BN_one(&mult);
+ bn_check(BN_one(&mult));
BN_init(&stop);
- BN_one(&stop);
+ bn_check(BN_one(&stop));
scale_number(&stop, b->scale);
i = 0;
@@ -362,11 +358,11 @@ printnumber(FILE *f, const struct number *b, u_int base)
p = get_digit(rem, digits, base);
int_part->scale = 0;
normalize(int_part, fract_part->scale);
- BN_sub(fract_part->number, fract_part->number,
- int_part->number);
+ bn_check(BN_sub(fract_part->number, fract_part->number,
+ int_part->number));
printwrap(f, p);
free(p);
- BN_mul_word(&mult, base);
+ bn_check(BN_mul_word(&mult, base));
}
free_number(num_base);
BN_free(&mult);
@@ -380,17 +376,17 @@ printnumber(FILE *f, const struct number *b, u_int base)
void
print_value(FILE *f, const struct value *value, const char *prefix, u_int base)
{
- fputs(prefix, f);
+ (void)fputs(prefix, f);
switch (value->type) {
case BCODE_NONE:
if (value->array != NULL)
- fputs("<array>", f);
+ (void)fputs("<array>", f);
break;
case BCODE_NUMBER:
printnumber(f, value->u.num, base);
break;
case BCODE_STRING:
- fputs(value->u.string, f);
+ (void)fputs(value->u.string, f);
break;
}
}
@@ -412,7 +408,7 @@ print_ascii(FILE *f, const struct number *n)
ch = 0;
for (i = 0; i < 8; i++)
ch |= BN_is_bit_set(v, numbits-i-1) << (7 - i);
- putc(ch, f);
+ (void)putc(ch, f);
numbits -= 8;
}
BN_free(v);
diff --git a/usr.bin/dc/stack.c b/usr.bin/dc/stack.c
index eecb035b9db..9ab98f9a799 100644
--- a/usr.bin/dc/stack.c
+++ b/usr.bin/dc/stack.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: stack.c,v 1.7 2005/03/28 17:39:20 deraadt Exp $ */
+/* $OpenBSD: stack.c,v 1.8 2006/01/15 19:11:59 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
@@ -17,7 +17,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: stack.c,v 1.7 2005/03/28 17:39:20 deraadt Exp $";
+static const char rcsid[] = "$OpenBSD: stack.c,v 1.8 2006/01/15 19:11:59 otto Exp $";
#endif /* not lint */
#include <err.h>
@@ -258,7 +258,7 @@ stack_print(FILE *f, const struct stack *stack, const char *prefix, u_int base)
for (i = stack->sp; i >= 0; i--) {
print_value(f, &stack->stack[i], prefix, base);
- putc('\n', f);
+ (void)putc('\n', f);
}
}
@@ -298,7 +298,7 @@ array_dup(const struct array *a)
n = array_new();
array_grow(n, a->size);
for (i = 0; i < a->size; i++)
- stack_dup_value(&a->data[i], &n->data[i]);
+ (void)stack_dup_value(&a->data[i], &n->data[i]);
return n;
}