All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Wysochanski <dwysocha@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH] Use struct cmd_context* as type for lvm2_handle_t with hidden cmd_context. Accessors and mutators have to be used. (lib/lvm2.h)
Date: Thu, 11 Dec 2008 13:45:14 -0500	[thread overview]
Message-ID: <1229021114.20795.6.camel@localhost.localdomain> (raw)
In-Reply-To: <1229013822-10809-1-git-send-email-twoerner@redhat.com>


On Thu, 2008-12-11 at 17:43 +0100, Thomas Woerner wrote:
> ---
>  lib/lvm2.h      |   23 +++++++++++------------
>  test/api/test.c |   13 ++++++-------
>  2 files changed, 17 insertions(+), 19 deletions(-)
> 
> diff --git a/lib/lvm2.h b/lib/lvm2.h
> index 8ddaf68..b131fd7 100644
> --- a/lib/lvm2.h
> +++ b/lib/lvm2.h
> @@ -1,5 +1,4 @@
>  /*
> - * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.  
>   * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
>   *
>   * This file is part of LVM2.
> @@ -17,37 +16,37 @@
>  
>  #include <stdint.h>
>  
> +/*** Library Initialisation ***/
> +
>  /*
> - * Library Initialisation
> - * FIXME: For now just #define lvm2_create() and lvm2_destroy() to 
> - * create_toolcontext() and destroy_toolcontext()
> + * lvm2_handle_t
>   */
> -struct arg;
> -struct cmd_context;
> -struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static, unsigned is_long_lived);
> -void destroy_toolcontext(struct cmd_context *cmd);
> +struct cmd_context; /* private context */
> +typedef struct cmd_context* lvm2_handle_t;
>  
>  /*
>   * lvm2_create
> -lvm_handle_t lvm2_create(void);
>   *
>   * Description: Create an LVM2 handle used in many other APIs.
>   *
> + * Parameters:
> + * - sys_dir: Directory containing lvm.conf and other LVM system files,
> + *            overwritten by LVM_SYSTEM_DIR environment variable (if set)
> + *
>   * Returns:
>   * NULL: Fail - unable to initialise handle.
>   * non-NULL: Success - valid LVM2 handle returned
>   */
> -#define lvm2_create(X) create_toolcontext(NULL,0,1)
> +lvm2_handle_t lvm2_create(const char *sys_dir);
>  
>  /*
>   * lvm2_destroy
> -void lvm2_destroy(lvm_handle_t h);
>   *
>   * Description: Destroy an LVM2 handle allocated with lvm2_create
>   *
>   * Parameters:
>   * - h (IN): handle obtained from lvm2_create
>   */
> -#define lvm2_destroy(X) destroy_toolcontext(X)
> +void lvm2_destroy(lvm2_handle_t h);

Might have been nice to leave the #defines until the later patch when
you actually add these functions but no big deal.

>  
>  #endif
> diff --git a/test/api/test.c b/test/api/test.c
> index de53c46..866be8f 100644
> --- a/test/api/test.c
> +++ b/test/api/test.c
> @@ -48,7 +48,7 @@ static int lvm_split(char *str, int *argc, char **argv, int max)
>  	return *argc;
>  }
>  
> -static int lvmapi_test_shell(void *h)
> +static int lvmapi_test_shell(lvm2_handle_t libh)
>  {
>  	int argc, i;
>  	char *input = NULL, *args[MAX_ARGS], **argv;
> @@ -99,18 +99,17 @@ static int lvmapi_test_shell(void *h)
>  		      
>  int main (int argc, char *argv[])
>  {
> -	void *h;
> +	lvm2_handle_t libh;
>  
> -	h = lvm2_create();
> -	if (!h) {
> +	libh = lvm2_create(NULL);
> +	if (!libh) {
>  		printf("Unable to open lvm library instance\n");
>  		return 1;
>  	}
>  
> -	lvmapi_test_shell(h);
> +	lvmapi_test_shell(libh);
>  
> -	if (h)
> -		lvm2_destroy(h);
> +	lvm2_destroy(libh);
>  	return 0;
>  }
>  

Looks ok.



  parent reply	other threads:[~2008-12-11 18:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-11 16:43 [PATCH] Use struct cmd_context* as type for lvm2_handle_t with hidden cmd_context. Accessors and mutators have to be used. (lib/lvm2.h) Thomas Woerner
2008-12-11 16:43 ` [PATCH] Renamed create_toolcontext function to _create_context and added sys_dir as argument, new functions create_librarycontext and create_toolcontext Thomas Woerner
2008-12-11 16:43   ` [PATCH] New lib/lvm2.c for base library functions Thomas Woerner
2008-12-11 16:43     ` [PATCH] New public functions lvm2_reload_config, lvm2_set_config_option and lvm2_reset_config_option Thomas Woerner
2008-12-11 21:49       ` Dave Wysochanski
2008-12-12  1:33         ` Alasdair G Kergon
2008-12-12 11:36         ` Thomas Woerner
2008-12-12 12:45           ` Alasdair G Kergon
2008-12-12 13:04           ` Dave Wysochanski
2008-12-12  1:11     ` [PATCH] New lib/lvm2.c for base library functions Alasdair G Kergon
2008-12-12  1:04   ` [PATCH] Renamed create_toolcontext function to _create_context and added sys_dir as argument, new functions create_librarycontext and create_toolcontext Alasdair G Kergon
2008-12-12  3:39     ` Dave Wysochanski
2008-12-11 18:45 ` Dave Wysochanski [this message]
2008-12-12  0:46 ` [PATCH] Use struct cmd_context* as type for lvm2_handle_t with hidden cmd_context. Accessors and mutators have to be used. (lib/lvm2.h) Alasdair G Kergon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1229021114.20795.6.camel@localhost.localdomain \
    --to=dwysocha@redhat.com \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.