Re: [PATCH 5/8] Align items in cmap_mcast_send

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ACK

On 10/1/2012 4:21 PM, Jan Friesse wrote:
> Aligning function (kernel style magic) MAR_ALIGN_UP is used for
> aligning of items in req_exec_cmap_mcast message.
> 
> Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
> ---
>  exec/cmap.c                |   15 +++++++++++----
>  include/corosync/mar_gen.h |    2 ++
>  2 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/exec/cmap.c b/exec/cmap.c
> index 5e61b03..8c30271 100644
> --- a/exec/cmap.c
> +++ b/exec/cmap.c
> @@ -114,6 +114,13 @@ static void message_handler_req_exec_cmap_mcast(
>  
>  static void exec_cmap_mcast_endian_convert(void *message);
>  
> +/*
> + * Reson is subtype of message. argc is number of items in argv array. Argv is array
> + * of strings (key names) which will be send to wire. There can be maximum
> + * MAX_REQ_EXEC_CMAP_MCAST_ITEMS items (for more items, CS_ERR_TOO_MANY_GROUPS
> + * error is returned). If key is not found, item has type ICMAP_VALUETYPE_NOT_EXIST
> + * and length zero.
> + */
>  static int cmap_mcast_send(enum cmap_mcast_reason reason, int argc, char *argv[]);
>  
>  /*
> @@ -203,7 +210,7 @@ struct req_exec_cmap_mcast {
>          mar_uint8_t reserved1 __attribute__((aligned(8)));
>          mar_uint8_t reserver2 __attribute__((aligned(8)));
>          /*
> -         * Following are array of req_exec_cmap_mcast_item
> +         * Following are array of req_exec_cmap_mcast_item alligned to 8 bytes
>           */
>  };
>  
> @@ -679,7 +686,7 @@ static int cmap_mcast_send(enum cmap_mcast_reason reason, int argc, char *argv[]
>  			value_len = 0;
>  		}
>  
> -		item_len = sizeof(*item) + value_len;
> +		item_len = MAR_ALIGN_UP(sizeof(*item) + value_len, 8);
>  
>  		item = malloc(item_len);
>  		if (item == NULL) {
> @@ -749,7 +756,7 @@ static struct req_exec_cmap_mcast_item *cmap_mcast_item_find(
>  			return (item);
>  		}
>  
> -		p += sizeof(*item) + item->value_len;
> +		p += MAR_ALIGN_UP(sizeof(*item) + item->value_len, 8);
>  	}
>  
>  	return (NULL);
> @@ -855,6 +862,6 @@ static void exec_cmap_mcast_endian_convert(void *message)
>  			break;
>  		}
>  
> -		p += sizeof(*item) + item->value_len;
> +		p += MAR_ALIGN_UP(sizeof(*item) + item->value_len, 8);
>  	}
>  }
> diff --git a/include/corosync/mar_gen.h b/include/corosync/mar_gen.h
> index ad16d14..d8fee0e 100644
> --- a/include/corosync/mar_gen.h
> +++ b/include/corosync/mar_gen.h
> @@ -41,6 +41,8 @@
>  #include <corosync/corotypes.h>
>  #include <corosync/swab.h>
>  
> +#define MAR_ALIGN_UP(addr,size) (((addr)+((size)-1))&(~((size)-1)))
> +
>  typedef int8_t mar_int8_t;
>  typedef int16_t mar_int16_t;
>  typedef int32_t mar_int32_t;
> 

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss


[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux