LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: meyering at sourceware.org 2007-08-07 09:06:05
Modified files:
. : WHATS_NEW daemons/clvmd : lvm-functions.c lvm-functions.h refresh_clvmd.c lib/activate : activate.c activate.h
lib/datastruct : btree.c btree.h list.c list.h str_list.c
str_list.h
lib/display : display.c display.h
lib/metadata : metadata-exported.h metadata.c
tools : toollib.c toollib.h tools.h vgdisplay.c
Log message:
Add "const" attributes where possible: first cut.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.678&r2=1.679
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.h.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/refresh_clvmd.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.125&r2=1.126
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.56&r2=1.57
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/datastruct/btree.c.diff?cvsroot=lvm2&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/datastruct/btree.h.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/datastruct/list.c.diff?cvsroot=lvm2&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/datastruct/list.h.diff?cvsroot=lvm2&r1=1.23&r2=1.24
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/datastruct/str_list.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/datastruct/str_list.h.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/display/display.c.diff?cvsroot=lvm2&r1=1.75&r2=1.76
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/display/display.h.diff?cvsroot=lvm2&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.130&r2=1.131
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.102&r2=1.103
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.h.diff?cvsroot=lvm2&r1=1.47&r2=1.48
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/tools.h.diff?cvsroot=lvm2&r1=1.53&r2=1.54
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgdisplay.c.diff?cvsroot=lvm2&r1=1.17&r2=1.18
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.28 - ================================ + Add const attributes where possible, first cut. Add support for renaming mirrored LVs. Factor out core of lvrename() to lv_rename lvm library function. Add --log argument to specify log type for mirrors.
daemons/clvmd/lvm-functions.c +1 -1
@@ -431,7 +431,7 @@ }/* Check if a VG is un use by LVM1 so we don't stomp on it */ -int do_check_lvm1 (char *vgname) +int do_check_lvm1 (const char *vgname) {int status;
daemons/clvmd/lvm-functions.h +1 -1
@@ -24,7 +24,7 @@ char *resource);extern int post_lock_lv (unsigned char lock_cmd,unsigned char lock_flags,char *resource); -extern int do_check_lvm1 (char *vgname); +extern int do_check_lvm1 (const char *vgname);extern int do_refresh_cache (void );extern int init_lvm (int using_gulm);extern void init_lvhash (void );
daemons/clvmd/refresh_clvmd.c +1 -1
@@ -79,7 +79,7 @@ }/* Send a request and return the status */ -static int _send_request (char *inbuf,int inlen,char **retbuf) +static int _send_request (const char *inbuf,int inlen,char **retbuf) {char outbuf[PIPE_BUF ];struct clvm_header *outheader = (struct clvm_header *) outbuf;
lib/activate/activate.c +2 -2
@@ -642,9 +642,9 @@return _lvs_in_vg_activated (vg,0 ); } -int lvs_in_vg_opened (struct volume_group *vg) +int lvs_in_vg_opened (const struct volume_group *vg) { -struct lv_list *lvl; +const struct lv_list *lvl;int count =0 ;if (!activation ())
lib/activate/activate.h +1 -1
@@ -84,7 +84,7 @@*/ int lvs_in_vg_activated (struct volume_group *vg);int lvs_in_vg_activated_by_uuid_only (struct volume_group *vg); -int lvs_in_vg_opened (struct volume_group *vg); +int lvs_in_vg_opened (const struct volume_group *vg); int monitor_dev_for_events(struct cmd_context *cmd,
lib/datastruct/btree.c +7 -6
@@ -55,7 +55,8 @@#endif } -static struct node **_lookup (struct node **c,uint32_t key,struct node **p) +static struct node **_lookup (struct node *const *c,uint32_t key, +struct node **p) { *p =NULL ;while (*c) {
@@ -70,10 +71,10 @@ c = &(*c)->r; } -return c; +return (struct node **)c; } -void *btree_lookup (struct btree *t,uint32_t k) +void *btree_lookup (const struct btree *t,uint32_t k) {uint32_t key =_shuffle (k);struct node *p, **c =_lookup (&t->root, key, &p);
@@ -102,7 +103,7 @@return 1 ; } -void *btree_get_data (struct btree_iter *it) +void *btree_get_data (const struct btree_iter *it) {return ((struct node *) it)->data; }
@@ -114,7 +115,7 @@return n; } -struct btree_iter *btree_first (struct btree *t) +struct btree_iter *btree_first (const struct btree *t) {if (!t->root)return NULL ;
@@ -122,7 +123,7 @@return (struct btree_iter *)_left (t->root); } -struct btree_iter *btree_next (struct btree_iter *it) +struct btree_iter *btree_next (const struct btree_iter *it) {struct node *n = (struct node *) it;uint32_t k = n->key;
lib/datastruct/btree.h +5 -5
@@ -1,5 +1,5 @@/* -* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. +* Copyright (C) 2001-2004, 2007 Sistina Software, Inc. All rights reserved. * Copyright (C) 2004 Red Hat, Inc. All rights reserved. * * This file is part of LVM2.
@@ -20,13 +20,13 @@struct btree *btree_create (struct dm_pool *mem); -void *btree_lookup (struct btree *t,uint32_t k); +void *btree_lookup (const struct btree *t,uint32_t k);int btree_insert (struct btree *t,uint32_t k,void *data);struct btree_iter ; -void *btree_get_data (struct btree_iter *it); +void *btree_get_data (const struct btree_iter *it); -struct btree_iter *btree_first (struct btree *t); -struct btree_iter *btree_next (struct btree_iter *it); +struct btree_iter *btree_first (const struct btree *t); +struct btree_iter *btree_next (const struct btree_iter *it);#endif
lib/datastruct/list.c +7 -7
@@ -68,7 +68,7 @@/* * Is the list empty? */ -int list_empty (struct list *head) +int list_empty (const struct list *head) {return head->n == head; }
@@ -76,7 +76,7 @@/* * Is this the first element of the list? */ -int list_start (struct list *head,struct list *elem) +int list_start (const struct list *head,const struct list *elem) {return elem->p == head; }
@@ -84,7 +84,7 @@/* * Is this the last element of the list? */ -int list_end (struct list *head,struct list *elem) +int list_end (const struct list *head,const struct list *elem) {return elem->n == head; }
@@ -92,7 +92,7 @@/* * Return first element of the list or NULL if empty */ -struct list *list_first (struct list *head) +struct list *list_first (const struct list *head) {return (list_empty (head) ?NULL : head->n); }
@@ -100,7 +100,7 @@/* * Return last element of the list or NULL if empty */ -struct list *list_last (struct list *head) +struct list *list_last (const struct list *head) {return (list_empty (head) ?NULL : head->p); }
@@ -108,7 +108,7 @@/* * Return the previous element of the list, or NULL if we've reached the start. */ -struct list *list_prev (struct list *head,struct list *elem) +struct list *list_prev (const struct list *head,const struct list *elem) {return (list_start (head, elem) ?NULL : elem->p); }
@@ -116,7 +116,7 @@/* * Return the next element of the list, or NULL if we've reached the end. */ -struct list *list_next (struct list *head,struct list *elem) +struct list *list_next (const struct list *head,const struct list *elem) {return (list_end (head, elem) ?NULL : elem->n); }
lib/datastruct/list.h +7 -7
@@ -57,37 +57,37 @@/* * Is the list empty? */ -int list_empty (struct list *head); +int list_empty (const struct list *head);/* * Is this the first element of the list? */ -int list_start (struct list *head,struct list *elem); +int list_start (const struct list *head,const struct list *elem);/* * Is this the last element of the list? */ -int list_end (struct list *head,struct list *elem); +int list_end (const struct list *head,const struct list *elem);/* * Return first element of the list or NULL if empty */ -struct list *list_first (struct list *head); +struct list *list_first (const struct list *head);/* * Return last element of the list or NULL if empty */ -struct list *list_last (struct list *head); +struct list *list_last (const struct list *head);/* * Return the previous element of the list, or NULL if we've reached the start. */ -struct list *list_prev (struct list *head,struct list *elem); +struct list *list_prev (const struct list *head,const struct list *elem);/* * Return the next element of the list, or NULL if we've reached the end. */ -struct list *list_next (struct list *head,struct list *elem); +struct list *list_next (const struct list *head,const struct list *elem);/* * Given the address v of an instance of 'struct list' called 'head'
lib/datastruct/str_list.c +5 -4
@@ -66,7 +66,8 @@return 1 ; } -int str_list_dup (struct dm_pool *mem,struct list *sllnew,struct list *sllold) +int str_list_dup (struct dm_pool *mem,struct list *sllnew, +const struct list *sllold) {struct str_list *sl;
@@ -85,7 +86,7 @@/* * Is item on list? */ -int str_list_match_item (struct list *sll,const char *str) +int str_list_match_item (const struct list *sll,const char *str) {struct str_list *sl;
@@ -99,7 +100,7 @@/* * Is at least one item on both lists? */ -int str_list_match_list (struct list *sll,struct list *sll2) +int str_list_match_list (const struct list *sll,const struct list *sll2) {struct str_list *sl;
@@ -113,7 +114,7 @@/* * Do both lists contain the same set of items? */ -int str_list_lists_equal (struct list *sll,struct list *sll2) +int str_list_lists_equal (const struct list *sll,const struct list *sll2) {struct str_list *sl;
lib/datastruct/str_list.h +5 -4
@@ -19,9 +19,10 @@struct list *str_list_create (struct dm_pool *mem);int str_list_add (struct dm_pool *mem,struct list *sll,const char *str);int str_list_del (struct list *sll,const char *str); -int str_list_match_item (struct list *sll,const char *str); -int str_list_match_list (struct list *sll,struct list *sll2); -int str_list_lists_equal (struct list *sll,struct list *sll2); -int str_list_dup (struct dm_pool *mem,struct list *sllnew,struct list *sllold); +int str_list_match_item (const struct list *sll,const char *str); +int str_list_match_list (const struct list *sll,const struct list *sll2); +int str_list_lists_equal (const struct list *sll,const struct list *sll2); +int str_list_dup (struct dm_pool *mem,struct list *sllnew, +const struct list *sllold);#endif
lib/display/display.c +26 -23
147 lines not on this page · raw message
lib/display/display.h +20 -18
@@ -23,32 +23,34 @@uint64_t units_to_bytes (const char *units,char *unit_type);/* Specify size in KB */ -const char *display_size (struct cmd_context *cmd,uint64_t size); -const char *display_size_long (struct cmd_context *cmd,uint64_t size); -const char *display_size_units (struct cmd_context *cmd,uint64_t size); +const char *display_size (const struct cmd_context *cmd,uint64_t size); +const char *display_size_long (const struct cmd_context *cmd,uint64_t size); +const char *display_size_units (const struct cmd_context *cmd,uint64_t size);char *display_uuid (char *uuidstr);void display_stripe (const struct lv_segment *seg,uint32_t s,const char *pre); -void pvdisplay_colons (struct physical_volume *pv); -void pvdisplay_segments (struct physical_volume *pv); -void pvdisplay_full (struct cmd_context *cmd,struct physical_volume *pv, +void pvdisplay_colons (const struct physical_volume *pv); +void pvdisplay_segments (const struct physical_volume *pv); +void pvdisplay_full (const struct cmd_context *cmd, +const struct physical_volume *pv,void *handle); -int pvdisplay_short (struct cmd_context *cmd,struct volume_group *vg, -struct physical_volume *pv,void *handle); - -void lvdisplay_colons (struct logical_volume *lv); -int lvdisplay_segments (struct logical_volume *lv); -int lvdisplay_full (struct cmd_context *cmd,struct logical_volume *lv, +int pvdisplay_short (const struct cmd_context *cmd, +const struct volume_group *vg, +const struct physical_volume *pv,void *handle); + +void lvdisplay_colons (const struct logical_volume *lv); +int lvdisplay_segments (const struct logical_volume *lv); +int lvdisplay_full (struct cmd_context *cmd,const struct logical_volume *lv,void *handle); -void vgdisplay_extents (struct volume_group *vg); -void vgdisplay_full (struct volume_group *vg); -void vgdisplay_colons (struct volume_group *vg); -void vgdisplay_short (struct volume_group *vg); +void vgdisplay_extents (const struct volume_group *vg); +void vgdisplay_full (const struct volume_group *vg); +void vgdisplay_colons (const struct volume_group *vg); +void vgdisplay_short (const struct volume_group *vg); -void display_formats (struct cmd_context *cmd); -void display_segtypes (struct cmd_context *cmd); +void display_formats (const struct cmd_context *cmd); +void display_segtypes (const struct cmd_context *cmd);/* * Allocation policy display conversion routines.
lib/metadata/metadata-exported.h +1 -1
@@ -397,7 +397,7 @@int vg_remove_snapshot (struct logical_volume *cow); -int vg_check_status (struct volume_group *vg,uint32_t status); +int vg_check_status (const struct volume_group *vg,uint32_t status);/* * Mirroring functions
lib/metadata/metadata.c +1 -1
@@ -1763,7 +1763,7 @@* 0 - fail * 1 - success */ -int vg_check_status (struct volume_group *vg,uint32_t status) +int vg_check_status (const struct volume_group *vg,uint32_t status) { if ((status & CLUSTERED) && (vg->status & CLUSTERED) && !locking_is_clustered() &&
tools/toollib.c +8 -11
@@ -25,7 +25,7 @@#define MIRROR_DISK_VERSION 2/* Command line args */ -unsigned arg_count (struct cmd_context *cmd,int a) +unsigned arg_count (const struct cmd_context *cmd,int a) {return cmd->args[a].count; }
@@ -142,12 +142,12 @@/* * Metadata iteration functions */ -int process_each_lv_in_vg (struct cmd_context *cmd,struct volume_group *vg, -struct list *arg_lvnames,struct list *tags, +int process_each_lv_in_vg (struct cmd_context *cmd, +const struct volume_group *vg, +const struct list *arg_lvnames, +const struct list *tags,void *handle, -int (*process_single) (struct cmd_context * cmd, -struct logical_volume * lv, -void *handle)) +process_single_lv_fn_t process_single) {int ret_max =0 ;int ret =0 ;
@@ -603,11 +603,8 @@ }int process_each_pv_in_vg (struct cmd_context *cmd,struct volume_group *vg, -struct list *tags,void *handle, -int (*process_single) (struct cmd_context * cmd, -struct volume_group * vg, -struct physical_volume * pv, -void *handle)) +const struct list *tags,void *handle, +process_single_pv_fn_t process_single) {int ret_max =0 ;int ret =0 ;
tools/toollib.h +16 -10
@@ -60,19 +60,25 @@struct lv_segment * seg, void *handle)); +typedef int (*process_single_pv_fn_t ) (struct cmd_context *cmd, +struct volume_group *vg, +struct physical_volume *pv, +void *handle); +int process_each_pv_in_vg (struct cmd_context *cmd,struct volume_group *vg, -struct list *tags,void *handle, -int (*process_single) (struct cmd_context * cmd, -struct volume_group * vg, -struct physical_volume * pv, -void *handle)); +const struct list *tags,void *handle, +process_single_pv_fn_t process_single); -int process_each_lv_in_vg (struct cmd_context *cmd,struct volume_group *vg, -struct list *arg_lvnames,struct list *tags, +typedef int (*process_single_lv_fn_t ) (struct cmd_context *cmd, +struct logical_volume *lv, +void *handle); + +int process_each_lv_in_vg (struct cmd_context *cmd, +const struct volume_group *vg, +const struct list *arg_lvnames, +const struct list *tags,void *handle, -int (*process_single) (struct cmd_context * cmd, -struct logical_volume * lv, -void *handle)); +process_single_lv_fn_t process_single);char *default_vgname (struct cmd_context *cmd);const char *extract_vgname (struct cmd_context *cmd,const char *lv_name);
tools/tools.h +1 -1
@@ -147,7 +147,7 @@char yes_no_prompt (const char *prompt, ...);/* we use the enums to access the switches */ -unsigned int arg_count (struct cmd_context *cmd,int a); +unsigned int arg_count (const struct cmd_context *cmd,int a);const char *arg_value (struct cmd_context *cmd,int a);const char *arg_str_value (struct cmd_context *cmd,int a,const char *def);int32_t arg_int_value (struct cmd_context *cmd,int a,const int32_t def);
tools/vgdisplay.c +4 -3
@@ -46,10 +46,11 @@vgdisplay_extents (vg);process_each_lv_in_vg (cmd, vg,NULL ,NULL ,NULL , - &lvdisplay_full); + (process_single_lv_fn_t )lvdisplay_full);log_print ("--- Physical volumes ---" ); -process_each_pv_in_vg (cmd, vg,NULL ,NULL , &pvdisplay_short); +process_each_pv_in_vg (cmd, vg,NULL ,NULL , + (process_single_pv_fn_t )pvdisplay_short); }check_current_backup (vg);
@@ -98,7 +99,7 @@**********/ process_each_vg (cmd, argc, argv,LCK_VG_READ ,0 ,NULL , - &vgdisplay_single); + vgdisplay_single);/******** FIXME Need to count number processed Add this to process_each_vg if arg_count(cmd,activevolumegroups_ARG) ?