From patchwork Sat Nov 3 12:50:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1692271 Return-Path: X-Original-To: patchwork-cifs-client@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 40F41DFB7B for ; Sat, 3 Nov 2012 12:50:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932135Ab2KCMus (ORCPT ); Sat, 3 Nov 2012 08:50:48 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:50361 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932075Ab2KCMus (ORCPT ); Sat, 3 Nov 2012 08:50:48 -0400 Received: by mail-gh0-f174.google.com with SMTP id g15so789442ghb.19 for ; Sat, 03 Nov 2012 05:50:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=2nUF8OpXQ5egupzo1GCPbRKeJoqMldcgiL14yMtKmK0=; b=kX86A/1nzx9G4yA2IqeL+Hl5L4eb/9Et7Ytyy0FTp/z10iQiAsGNuEjemoL54Gb1P5 By+VVgSOauf1/Yraiy4GnpuqG00GmhJ68ck0PsnfuhV7M7zb/7sizvvJg4leNUADmP0G xLDbFFhpuYzQv8JOVuH9rZG3UMtRxgRc8joIQ2dy69btiNiVuGRsiShcUc74qPi6rJYa ioss0+Jdkpz0DJIKDLjWQczeOQcBlgrfEpnZkfc9x7RHi9w/4A4jH+WpSQEF/dqSDkKr dwYvrhJdpd3bQJSOLOdZBBHFaFrW53gOB1lEzAn9us5+tAjq3AnR0baXw8BxfN+bq3ZQ EmeA== Received: by 10.236.76.132 with SMTP id b4mr4240809yhe.106.1351947048050; Sat, 03 Nov 2012 05:50:48 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-107-015-110-129.nc.res.rr.com. [107.15.110.129]) by mx.google.com with ESMTPS id n13sm11145727ano.20.2012.11.03.05.50.46 (version=SSLv3 cipher=OTHER); Sat, 03 Nov 2012 05:50:47 -0700 (PDT) From: Jeff Layton To: linux-cifs@vger.kernel.org Cc: shirishpargaonkar@gmail.com Subject: [PATCH 05/17] setcifsacl: declare an enum for the action values Date: Sat, 3 Nov 2012 08:50:22 -0400 Message-Id: <1351947034-18876-6-git-send-email-jlayton@samba.org> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1351947034-18876-1-git-send-email-jlayton@samba.org> References: <1351947034-18876-1-git-send-email-jlayton@samba.org> X-Gm-Message-State: ALoCoQk7Pz0mDRo0iktgx0R7iDZBIz2XNfZZ20kfMfaLxikRo4SQuTNO8toOSNjna5coJCPXCyzA Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org ...instead of relying on magic values of an int. Signed-off-by: Jeff Layton --- setcifsacl.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/setcifsacl.c b/setcifsacl.c index 50822e6..71b065c 100644 --- a/setcifsacl.c +++ b/setcifsacl.c @@ -41,6 +41,14 @@ static const char *prog; +enum setcifsacl_actions { + ActUnknown = -1, + ActDelete, + ActModify, + ActAdd, + ActSet +}; + static void copy_sec_desc(const struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, int numaces, int acessize) @@ -708,24 +716,24 @@ static int setacl_action(struct cifs_ntsd *pntsd, struct cifs_ntsd **npntsd, ssize_t *bufsize, struct cifs_ace **facesptr, int numfaces, struct cifs_ace **cacesptr, int numcaces, - int maction) + enum setcifsacl_actions maction) { int rc = 1; switch (maction) { - case 0: + case ActDelete: rc = ace_delete(pntsd, npntsd, bufsize, facesptr, numfaces, cacesptr, numcaces); break; - case 1: + case ActModify: rc = ace_modify(pntsd, npntsd, bufsize, facesptr, numfaces, cacesptr, numcaces); break; - case 2: + case ActAdd: rc = ace_add(pntsd, npntsd, bufsize, facesptr, numfaces, cacesptr, numcaces); break; - case 3: + case ActSet: rc = ace_set(pntsd, npntsd, bufsize, cacesptr, numcaces); break; default: @@ -768,7 +776,8 @@ setcifsacl_usage(void) int main(const int argc, char *const argv[]) { - int i, rc, c, numcaces, numfaces, maction = -1; + int i, rc, c, numcaces, numfaces; + enum setcifsacl_actions maction = ActUnknown; ssize_t attrlen, bufsize = BUFSIZE; char *filename, *attrval, **arrptr = NULL; struct cifs_ctrl_acl *daclptr = NULL; @@ -785,16 +794,16 @@ main(const int argc, char *const argv[]) printf("Version: %s\n", VERSION); goto out; case 'D': - maction = 0; + maction = ActDelete; break; case 'M': - maction = 1; + maction = ActModify; break; case 'a': - maction = 2; + maction = ActAdd; break; case 'S': - maction = 3; + maction = ActSet; break; case '?': setcifsacl_usage(); @@ -849,7 +858,7 @@ cifsacl: } numfaces = get_numfaces((struct cifs_ntsd *)attrval, attrlen, &daclptr); - if (!numfaces && maction != 2) { /* if we are not adding aces */ + if (!numfaces && maction != ActAdd) { /* if we are not adding aces */ printf("%s: Empty DACL\n", __func__); goto setcifsacl_facenum_ret; }