From d896527d21107afe69328ac465a3d2f0e318ddca Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 7 Jul 2010 17:12:42 -0500 Subject: fgets invocation cleanup From the fgets manpage: fgets() reads in at most one less than size characters from stream and stores them into the buffer pointed to by s. Reading stops after an EOF or a newline. If a newline is read, it is stored into the buffer. A '\0' is stored after the last character in the buffer. This means there is no need at all to do 'size - 1' math. Remove all of that and just use sizeof() for simplicity on the buffer we plan on reading into. Signed-off-by: Dan McGee --- src/pacman/util.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/pacman/util.c b/src/pacman/util.c index d117cd39..dbac29bf 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -690,7 +690,6 @@ void display_optdepends(pmpkg_t *pkg) static int question(short preset, char *fmt, va_list args) { char response[32]; - int sresponse = sizeof(response)-1; FILE *stream; if(config->noconfirm) { @@ -713,7 +712,7 @@ static int question(short preset, char *fmt, va_list args) return(preset); } - if(fgets(response, sresponse, stdin)) { + if(fgets(response, sizeof(response), stdin)) { strtrim(response); if(strlen(response) == 0) { return(preset); -- cgit v1.2.3-70-g09d2