Skip to content

Commit

Permalink
Change getsn() to use size_t for size values.
Browse files Browse the repository at this point in the history
The size argument and the return value both describe the size of a
memory area, thus size_t is justified.

ok pedro@
  • Loading branch information
natano committed Mar 17, 2015
1 parent f26d335 commit be8a972
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions share/man/man9/kern.9
Expand Up @@ -239,8 +239,8 @@ and
.Xr strncasecmp 3 .
.Sh MISCELLANEOUS
.nr nS 1
.Ft int
.Fn getsn "char *cp" "int size"
.Ft size_t
.Fn getsn "char *cp" "size_t size"
.nr nS 0
.Pp
The
Expand Down
6 changes: 2 additions & 4 deletions sys/kern/subr_userconf.c
Expand Up @@ -421,14 +421,13 @@ userconf_modify(char *item, int *val)
int ok = 0;
int a;
char *c;
int i;

while (!ok) {
printf("%s [", item);
userconf_pnum(*val);
printf("] ? ");

i = getsn(userconf_argbuf, sizeof(userconf_argbuf));
(void)getsn(userconf_argbuf, sizeof(userconf_argbuf));

c = userconf_argbuf;
while (*c == ' ' || *c == '\t' || *c == '\n') c++;
Expand Down Expand Up @@ -994,14 +993,13 @@ userconf_add_read(char *prompt, char field, char *dev, int len, int *val)
int ok = 0;
int a;
char *c;
int i;

*val = -1;

while (!ok) {
printf("%s ? ", prompt);

i = getsn(userconf_argbuf, sizeof(userconf_argbuf));
(void)getsn(userconf_argbuf, sizeof(userconf_argbuf));

c = userconf_argbuf;
while (*c == ' ' || *c == '\t' || *c == '\n')
Expand Down
7 changes: 4 additions & 3 deletions sys/lib/libkern/getsn.c
Expand Up @@ -29,10 +29,11 @@
#include <sys/systm.h>
#include <dev/cons.h>

int
getsn(char *cp, int size)
size_t
getsn(char *cp, size_t size)
{
int len = 0, c;
size_t len = 0;
int c;
char *lp = cp;

while (1) {
Expand Down
2 changes: 1 addition & 1 deletion sys/lib/libkern/libkern.h
Expand Up @@ -176,7 +176,7 @@ size_t strlcat(char *, const char *, size_t)
int strcmp(const char *, const char *);
int strncmp(const char *, const char *, size_t);
int strncasecmp(const char *, const char *, size_t);
int getsn(char *, int);
size_t getsn(char *, size_t);
char *strchr(const char *, int);
char *strrchr(const char *, int);
int timingsafe_bcmp(const void *, const void *, size_t);
Expand Down

0 comments on commit be8a972

Please sign in to comment.