diff options
author | Dan McGee <dan@archlinux.org> | 2010-07-07 17:12:42 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-08-23 21:48:28 -0500 |
commit | d896527d21107afe69328ac465a3d2f0e318ddca (patch) | |
tree | 9cf121bd6883d5d89c9ca942d0b0c387656d2208 /lib/libalpm/trans.c | |
parent | ce3f4e7800f215e8a2b6e22bbd5f5ec9e0de90c2 (diff) | |
download | pacman-d896527d21107afe69328ac465a3d2f0e318ddca.tar.xz |
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 <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/trans.c')
-rw-r--r-- | lib/libalpm/trans.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 523f33b8..3c5141a1 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -323,10 +323,11 @@ static int grep(const char *fn, const char *needle) } while(!feof(fp)) { char line[1024]; - int sline = sizeof(line)-1; - if(fgets(line, sline, fp) == NULL) { + if(fgets(line, sizeof(line), fp) == NULL) { continue; } + /* TODO: this will not work if the search string + * ends up being split across line reads */ if(strstr(line, needle)) { fclose(fp); return(1); |