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: 397 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx21.g.dreamhost.com (peon2454.g.dreamhost.com [208.113.200.127]) by wilcox.dreamhost.com (Postfix) with ESMTP id 4CF9F360099 for ; Thu, 3 Apr 2014 08:08:53 -0700 (PDT) Received: by homiemail-mx21.g.dreamhost.com (Postfix, from userid 14307373) id 00B34E65893; Thu, 3 Apr 2014 08:08:52 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx21.g.dreamhost.com 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 homiemail-mx21.g.dreamhost.com (Postfix) with ESMTPS id AA6B7E30F6C for ; Thu, 3 Apr 2014 08:08:52 -0700 (PDT) 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=xyqF mxVl8cMeNigR5opeYUdg+YA/yWu6AaisZv4/noSk8571ZwY7CRn13GfyB9K8pvbg OS8HszIvn1g6ZiBisvbrcaCJPSGYGudmUyeQnTvBwkjcnf8/BKfuCSlU87p+I1I4 HR67K2hdTTXXmM62R+Kezfym4kDRlDh9NIhWCs0= 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=pVIqA6snkAyNkcHV4cVcmHWlcQLMtdRz6l/FXPycGY PlSL0UEES+ffC0Iqq1HkuNH63MftSEsuS/mhAN14QpcfxKeBHIFHtaBsjtRkEQAm hNKuSwNrt/OMUQ1wF9b3sk78Yjf71BS/u6wEtwHSGPkCGqlzlr1ZrlO3LS2uGLYB 0= 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) X-DH-Original-To: glibc@patchwork.siddhesh.in 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. */