From patchwork Mon Oct 22 16:05:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 1626711 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 936D9DFB79 for ; Mon, 22 Oct 2012 16:05:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755302Ab2JVQF5 (ORCPT ); Mon, 22 Oct 2012 12:05:57 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:60605 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755157Ab2JVQF5 (ORCPT ); Mon, 22 Oct 2012 12:05:57 -0400 Received: by mail-ie0-f174.google.com with SMTP id k13so3828544iea.19 for ; Mon, 22 Oct 2012 09:05:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:subject:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=omZ8Al9rd08LNJgtg/nWK21f9pxCBRdlxOTf3Bk++fQ=; b=x1qhfMgiPSsez5xipgWKNMnuH1WPXvltoCKiGR7Jq/YDfZILOmuVDBHFKKTBzTr7X6 Pfl5uGwyXCo379l3MKaS2WA5U++T0qOftaOdkVoXnahtr8NPNQcfJjMGectyv7PvopnK MwwBcj8/6w0rBO759mLPqwy6jRPOy2b9jx/8ykHCRdZwbCpCacmhKaQHZZcyGwSBzCPq RqStDNQnOwJSUCIx231Jq9OvXhTbclhyGE8QDKHC80WpTDRX10jxn1ux9/7xrrxEnCan HXsrkdvpv0Om16+n+BTql5T37IwuekfrMUFSJ5k/Z1k/e+PGpxkMMIZBuhDGhXn++cYA nBUQ== Received: by 10.42.61.196 with SMTP id v4mr8219911ich.24.1350921956963; Mon, 22 Oct 2012 09:05:56 -0700 (PDT) Received: from lebasque.1015granger.net (adsl-99-26-161-222.dsl.sfldmi.sbcglobal.net. [99.26.161.222]) by mx.google.com with ESMTPS id x7sm8919998igk.8.2012.10.22.09.05.56 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 22 Oct 2012 09:05:56 -0700 (PDT) From: Chuck Lever Subject: [PATCH 02/10] mountd: Avoid unnecessary type conversions To: steved@redhat.com Cc: linux-nfs@vger.kernel.org Date: Mon, 22 Oct 2012 12:05:55 -0400 Message-ID: <20121022160555.4552.44389.stgit@lebasque.1015granger.net> In-Reply-To: <20121022160140.4552.34477.stgit@lebasque.1015granger.net> References: <20121022160140.4552.34477.stgit@lebasque.1015granger.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Clean up compiler warnings: cache.c: In function ‘auth_unix_ip’: cache.c:121:29: warning: conversion to ‘unsigned int’ from ‘time_t’ may alter its value [-Wconversion] cache.c: In function ‘auth_unix_gid’: cache.c:186:29: warning: conversion to ‘unsigned int’ from ‘time_t’ may alter its value [-Wconversion] cache.c: In function ‘dump_to_cache’: cache.c:733:30: warning: conversion to ‘unsigned int’ from ‘time_t’ may alter its value [-Wconversion] cache.c:753:30: warning: conversion to ‘unsigned int’ from ‘time_t’ may alter its value [-Wconversion] cache.c: In function ‘cache_export’: cache.c:1324:29: warning: conversion to ‘unsigned int’ from ‘time_t’ may alter its value [-Wconversion] Seen with gcc version 4.6.3 20120306 (Red Hat 4.6.3-2) (GCC) We can take the opportunity to eliminate some code duplication. Signed-off-by: Chuck Lever --- support/include/nfslib.h | 1 + support/nfs/cacheio.c | 5 +++++ utils/mountd/cache.c | 10 +++++----- 3 files changed, 11 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/support/include/nfslib.h b/support/include/nfslib.h index 73f3c20..f210a06 100644 --- a/support/include/nfslib.h +++ b/support/include/nfslib.h @@ -164,6 +164,7 @@ void qword_adduint(char **bpp, int *lp, unsigned int n); void qword_addeol(char **bpp, int *lp); int qword_get_uint(char **bpp, unsigned int *anint); void qword_printuint(FILE *f, unsigned int num); +void qword_printtimefrom(FILE *f, unsigned int num); void closeall(int min); diff --git a/support/nfs/cacheio.c b/support/nfs/cacheio.c index 9bad8e6..e641c45 100644 --- a/support/nfs/cacheio.c +++ b/support/nfs/cacheio.c @@ -153,6 +153,11 @@ void qword_printuint(FILE *f, unsigned int num) fprintf(f, "%u ", num); } +void qword_printtimefrom(FILE *f, unsigned int num) +{ + fprintf(f, "%lu ", time(0) + num); +} + int qword_eol(FILE *f) { int err; diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c index 8280234..6de05f1 100644 --- a/utils/mountd/cache.c +++ b/utils/mountd/cache.c @@ -118,7 +118,7 @@ static void auth_unix_ip(FILE *f) } qword_print(f, "nfsd"); qword_print(f, ipaddr); - qword_printuint(f, time(0) + DEFAULT_TTL); + qword_printtimefrom(f, DEFAULT_TTL); if (use_ipaddr) qword_print(f, ipaddr); else if (client) @@ -183,7 +183,7 @@ static void auth_unix_gid(FILE *f) } } qword_printuint(f, uid); - qword_printuint(f, time(0) + DEFAULT_TTL); + qword_printtimefrom(f, DEFAULT_TTL); if (rv >= 0) { qword_printuint(f, ngroups); for (i=0; ie_path) != 0; int flag_mask = different_fs ? ~NFSEXP_FSID : ~0; - qword_printuint(f, time(0) + exp->e_ttl); + qword_printtimefrom(f, exp->e_ttl); qword_printint(f, exp->e_flags & flag_mask); qword_printint(f, exp->e_anonuid); qword_printint(f, exp->e_anongid); @@ -750,7 +750,7 @@ static int dump_to_cache(FILE *f, char *domain, char *path, struct exportent *ex qword_printhex(f, u, 16); } } else - qword_printuint(f, time(0) + DEFAULT_TTL); + qword_printtimefrom(f, DEFAULT_TTL); return qword_eol(f); } @@ -1339,7 +1339,7 @@ int cache_export(nfs_export *exp, char *path) qword_print(f, "nfsd"); qword_print(f, host_ntop(get_addrlist(exp->m_client, 0), buf, sizeof(buf))); - qword_printuint(f, time(0) + exp->m_export.e_ttl); + qword_printtimefrom(f, exp->m_export.e_ttl); qword_print(f, exp->m_client->m_hostname); err = qword_eol(f);