From 7d03c9cbcedb1dc7e3a8210ac0001120558ec6df Mon Sep 17 00:00:00 2001 From: Bruce Beare Date: Fri, 21 Oct 2011 10:16:11 +0800 Subject: [PATCH] pathconf: dead loop in bionic function __2_symlinks Fix dead loops in file ./bionic/libc/unistd/pathconf.c Change-Id: I7a1e6bcd9879c96bacfd376b88a1f899793295c8 Author: Jin Wei Signed-off-by: Bruce Beare --- libc/unistd/pathconf.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/libc/unistd/pathconf.c b/libc/unistd/pathconf.c index 032f91845..26b580ffa 100644 --- a/libc/unistd/pathconf.c +++ b/libc/unistd/pathconf.c @@ -70,13 +70,12 @@ __filesizebits( struct statfs* s ) }; int nn = 0; - for (;;) { - if ( known64[nn] == EOL_MAGIC ) - return 32; - - if ( known64[nn] == s->f_type ) + for (; known64[nn] != EOL_MAGIC; ++nn) { + if (known64[nn] == s->f_type) { return 64; + } } + return 32; } @@ -99,12 +98,10 @@ __link_max( struct statfs* s ) }; int nn = 0; - for (;;) { - if ( knownMax[nn].type == EOL_MAGIC ) - return LINK_MAX; - - if ( knownMax[nn].type == s->f_type ) + for (; knownMax[nn].type != EOL_MAGIC; ++nn) { + if (knownMax[nn].type == s->f_type) { return knownMax[nn].max; + } } return LINK_MAX; } @@ -121,12 +118,12 @@ __2_symlinks( struct statfs* s ) }; int nn = 0; - for (;;) { - if (knownNoSymlinks[nn] == 0) - return 1; - if (knownNoSymlinks[nn] == s->f_type) + for (; knownNoSymlinks[nn] != EOL_MAGIC; ++nn) { + if (knownNoSymlinks[nn] == s->f_type) { return 0; + } } + return 1; } static long