From patchwork Thu Apr 3 15:09:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 336654 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 348D114009B for ; Fri, 4 Apr 2014 02:08:55 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:in-reply-to; q=dns; s=default; b=A/od O9OQU3OYrlk8nMZtISXjoe8yPejqU4QyXiCfqacv2p1VAP/YFbuk1sg6aQCM3k0t acQ+R1AXy50io6nJe+oQcoF7hVS21QCzCI4bprC7s0W0KtQrI2Syxv6tEyiwGCL3 YpANE+5lM+OdNkRlYhLTar0BheGn+rLUkHuvFBA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:in-reply-to; s=default; bh=+h7Rfo8h1a +npqjvTq+5c7Sapzo=; b=msMegpXkNXfZAmYG5cgDvrEWnrrX+l2mM6I50435up 9TPJfhg1Y+YxYvGGN3iKM13hMPB4DHVm3IvPchVDvUu8DEVXDAOuGcFl8rRPIbzp iIEX8cVYkLHzyskFfbQWmyO/4YXaNi6l9sExXZhdXUqygMHZojIlJ1B4M63qISOO U= Received: (qmail 23908 invoked by alias); 3 Apr 2014 15:08:49 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 23898 invoked by uid 89); 3 Apr 2014 15:08:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Date: Thu, 3 Apr 2014 20:39:21 +0530 From: Siddhesh Poyarekar To: Mike Frysinger Cc: libc-alpha@sourceware.org, Roland McGrath Subject: Re: [PATCH 2/2] Initialize all of datahead structure in nscd [BZ #16791] Message-ID: <20140403150921.GA5063@spoyarek.pnq.redhat.com> References: <20140401164104.GH16484@spoyarek.pnq.redhat.com> <24966439.irburZmzZi@vapier> <20140402094011.GD23931@spoyarek.pnq.redhat.com> <2541735.7QtA0LDnTJ@vapier> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2541735.7QtA0LDnTJ@vapier> User-Agent: Mutt/1.5.22.1-rc1 (2013-10-16) On Wed, Apr 02, 2014 at 05:42:23AM -0400, Mike Frysinger wrote: > doesn't GNU style say there should be a new line between decls and code ? or > do we not care about that rule in glibc ? I don't remember this being reviewed strictly, but maybe I just never made that mistake before. Anyway, fixed: Siddhesh diff --git a/nscd/nscd-client.h b/nscd/nscd-client.h index c069bf6..ee16df6 100644 --- a/nscd/nscd-client.h +++ b/nscd/nscd-client.h @@ -240,12 +240,17 @@ static inline time_t datahead_init_common (struct datahead *head, nscd_ssize_t allocsize, nscd_ssize_t recsize, uint32_t ttl) { + /* Initialize so that we don't write out junk in uninitialized data to the + cache. */ + memset (head, 0, sizeof (*head)); + head->allocsize = allocsize; head->recsize = recsize; head->usable = true; head->ttl = ttl; - /* Compute the timeout time. */ + + /* Compute and return the timeout time. */ return head->timeout = time (NULL) + ttl; } @@ -253,18 +258,25 @@ static inline time_t datahead_init_pos (struct datahead *head, nscd_ssize_t allocsize, nscd_ssize_t recsize, uint8_t nreloads, uint32_t ttl) { + time_t ret = datahead_init_common (head, allocsize, recsize, ttl); + head->notfound = false; head->nreloads = nreloads; - return datahead_init_common (head, allocsize, recsize, ttl); + + return ret; } static inline time_t datahead_init_neg (struct datahead *head, nscd_ssize_t allocsize, nscd_ssize_t recsize, uint32_t ttl) { + time_t ret = datahead_init_common (head, allocsize, recsize, ttl); + + /* We don't need to touch nreloads here since it is set to our desired value + (0) when we clear the structure. */ head->notfound = true; - head->nreloads = 0; - return datahead_init_common (head, allocsize, recsize, ttl); + + return ret; } /* Structure for one hash table entry. */