number = pwddb;
else if (strcmp (key, "group") == 0)
number = grpdb;
- else if (strcmp (key, "hosts") == 0)
+ else if (__builtin_expect (strcmp (key, "hosts"), 0) == 0)
number = hstdb;
- else return;
+ else
+ return;
if (dbs[number].enabled)
prune_cache (&dbs[number], LONG_MAX);
static void
handle_request (int fd, request_header *req, void *key, uid_t uid)
{
- if (debug_level > 0)
+ if (__builtin_expect (debug_level, 0) > 0)
dbg_log (_("handle_request: request received (Version = %d)"),
req->version);
- if (req->version != NSCD_VERSION)
+ if (__builtin_expect (req->version, NSCD_VERSION) != NSCD_VERSION)
{
if (debug_level > 0)
dbg_log (_("\
return;
}
- if (req->type >= GETPWBYNAME && req->type <= LASTDBREQ)
+ if (__builtin_expect (req->type, GETPWBYNAME) >= GETPWBYNAME
+ && __builtin_expect (req->type, LASTDBREQ) <= LASTDBREQ)
{
struct hashentry *cached;
struct database *db = &dbs[serv2db[req->type]];
- if (debug_level > 0)
+ if (__builtin_expect (debug_level, 0) > 0)
{
if (req->type == GETHOSTBYADDR || req->type == GETHOSTBYADDRv6)
{
if (TEMP_FAILURE_RETRY (write (fd, db->disabled_iov->iov_base,
db->disabled_iov->iov_len))
!= db->disabled_iov->iov_len
- && debug_level > 0)
+ && __builtin_expect (debug_level, 0) > 0)
{
/* We have problems sending the result. */
char buf[256];
/* Hurray it's in the cache. */
if (TEMP_FAILURE_RETRY (write (fd, cached->packet, cached->total))
!= cached->total
- && debug_level > 0)
+ && __builtin_expect (debug_level, 0) > 0)
{
/* We have problems sending the result. */
char buf[256];
pthread_rwlock_unlock (&db->lock);
}
- else if (debug_level > 0)
+ else if (__builtin_expect (debug_level, 0) > 0)
{
if (req->type == INVALIDATE)
dbg_log ("\t%s (%s)", serv2str[req->type], (char *)key);
char buf[256];
uid_t uid = 0;
- if (fd < 0)
+ if (__builtin_expect (fd, 0) < 0)
{
dbg_log (_("while accepting connection: %s"),
strerror_r (errno, buf, sizeof (buf)));
}
/* Now read the request. */
- if (TEMP_FAILURE_RETRY (read (fd, &req, sizeof (req)))
- != sizeof (req))
+ if (__builtin_expect (TEMP_FAILURE_RETRY (read (fd, &req,
+ sizeof (req)))
+ != sizeof (req), 0))
{
if (debug_level > 0)
dbg_log (_("short read while reading request: %s"),
/* It should not be possible to crash the nscd with a silly
request (i.e., a terribly large key). We limit the size
to 1kb. */
- if (req.key_len < 0 || req.key_len > 1024)
+ if (__builtin_expect (req.key_len, 1) < 0
+ || __builtin_expect (req.key_len, 1) > 1024)
{
if (debug_level > 0)
dbg_log (_("key length in request too long: %d"), req.key_len);
/* Get the key. */
char keybuf[req.key_len];
- if (TEMP_FAILURE_RETRY (read (fd, keybuf, req.key_len))
- != req.key_len)
+ if (__builtin_expect (TEMP_FAILURE_RETRY (read (fd, keybuf,
+ req.key_len))
+ != req.key_len, 0))
{
if (debug_level > 0)
dbg_log (_("short read while reading request key: %s"),
/* We write the dataset before inserting it to the database
since while inserting this thread might block and so would
unnecessarily let the receiver wait. */
- written = write (fd, data, total);
+ written = TEMP_FAILURE_RETRY (write (fd, data, total));
addr_list_type = (hst->h_length == NS_INADDRSZ
? GETHOSTBYADDR : GETHOSTBYADDRv6);
pthread_rwlock_unlock (&db->lock);
}
- if (written != total && debug_level > 0)
+ if (__builtin_expect (written != total, 0) && debug_level > 0)
{
char buf[256];
dbg_log (_("short write in %s: %s"), __FUNCTION__,
/* We write the dataset before inserting it to the database
since while inserting this thread might block and so would
unnecessarily let the receiver wait. */
- written = write (fd, &data->resp, total);
+ written = TEMP_FAILURE_RETRY (write (fd, &data->resp, total));
/* Compute the timeout time. */
t += db->postimeout;
pthread_rwlock_unlock (&db->lock);
}
- if (written != total && debug_level > 0)
+ if (__builtin_expect (written != total, 0) && debug_level > 0)
{
char buf[256];
dbg_log (_("short write in %s: %s"), __FUNCTION__,