good for merge

regards
-steve

On Mon, 2009-04-06 at 21:09 +0200, Jim Meyering wrote:
> Just const additions...
> 
> From e83ddcb3a0ea1a0e4db35db9577f8e54933e2aa6 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <[email protected]>
> Date: Mon, 6 Apr 2009 21:08:34 +0200
> Subject: [PATCH] totemip.h: const'ify
> 
> * include/corosync/totem/totemip.h: Add const to prototypes.
> * exec/totemip.c (totemip_equal, totemip_copy): Adjust.
> (totemip_copy_endian_convert, totemip_localhost_check): Likewise.
> (totemip_sockaddr_to_totemip_convert): Likewise.
> ---
>  exec/totemip.c                   |   19 ++++++++++++-------
>  include/corosync/totem/totemip.h |   24 ++++++++++++++++--------
>  2 files changed, 28 insertions(+), 15 deletions(-)
> 
> diff --git a/exec/totemip.c b/exec/totemip.c
> index 2531810..c3bd6c3 100644
> --- a/exec/totemip.c
> +++ b/exec/totemip.c
> @@ -87,7 +87,8 @@ void totemip_nosigpipe(int s)
>  #endif
> 
>  /* Compare two addresses */
> -int totemip_equal(struct totem_ip_address *addr1, struct totem_ip_address 
> *addr2)
> +int totemip_equal(const struct totem_ip_address *addr1,
> +               const struct totem_ip_address *addr2)
>  {
>       int addrlen = 0;
> 
> @@ -110,12 +111,14 @@ int totemip_equal(struct totem_ip_address *addr1, 
> struct totem_ip_address *addr2
>  }
> 
>  /* Copy a totem_ip_address */
> -void totemip_copy(struct totem_ip_address *addr1, struct totem_ip_address 
> *addr2)
> +void totemip_copy(struct totem_ip_address *addr1,
> +               const struct totem_ip_address *addr2)
>  {
>       memcpy(addr1, addr2, sizeof(struct totem_ip_address));
>  }
> 
> -void totemip_copy_endian_convert(struct totem_ip_address *addr1, struct 
> totem_ip_address *addr2)
> +void totemip_copy_endian_convert(struct totem_ip_address *addr1,
> +                              const struct totem_ip_address *addr2)
>  {
>       addr1->nodeid = swab32(addr2->nodeid);
>       addr1->family = swab16(addr2->family);
> @@ -198,7 +201,7 @@ int totemip_localhost(int family, struct totem_ip_address 
> *localhost)
>       return 0;
>  }
> 
> -int totemip_localhost_check(struct totem_ip_address *addr)
> +int totemip_localhost_check(const struct totem_ip_address *addr)
>  {
>       struct totem_ip_address localhost;
> 
> @@ -287,7 +290,8 @@ int totemip_parse(struct totem_ip_address *totemip, const 
> char *addr, int family
>  }
> 
>  /* Make a sockaddr_* into a totem_ip_address */
> -int totemip_sockaddr_to_totemip_convert(struct sockaddr_storage *saddr, 
> struct totem_ip_address *ip_addr)
> +int totemip_sockaddr_to_totemip_convert(const struct sockaddr_storage *saddr,
> +                                     struct totem_ip_address *ip_addr)
>  {
>       int ret = -1;
> 
> @@ -295,14 +299,15 @@ int totemip_sockaddr_to_totemip_convert(struct 
> sockaddr_storage *saddr, struct t
>       ip_addr->nodeid = 0;
> 
>       if (saddr->ss_family == AF_INET) {
> -             struct sockaddr_in *sin = (struct sockaddr_in *)saddr;
> +             const struct sockaddr_in *sin = (const struct sockaddr_in 
> *)saddr;
> 
>               memcpy(ip_addr->addr, &sin->sin_addr, sizeof(struct in_addr));
>               ret = 0;
>       }
> 
>       if (saddr->ss_family == AF_INET6) {
> -             struct sockaddr_in6 *sin = (struct sockaddr_in6 *)saddr;
> +             const struct sockaddr_in6 *sin
> +               = (const struct sockaddr_in6 *)saddr;
> 
>               memcpy(ip_addr->addr, &sin->sin6_addr, sizeof(struct in6_addr));
> 
> diff --git a/include/corosync/totem/totemip.h 
> b/include/corosync/totem/totemip.h
> index 26b1cbd..efc8e83 100644
> --- a/include/corosync/totem/totemip.h
> +++ b/include/corosync/totem/totemip.h
> @@ -6,7 +6,7 @@
>   * Author: Patrick Caulfield ([email protected])
>   *
>   * This software licensed under BSD license, the text of which follows:
> - * 
> + *
>   * Redistribution and use in source and binary forms, with or without
>   * modification, are permitted provided that the following conditions are 
> met:
>   *
> @@ -61,26 +61,34 @@ struct totem_ip_address
>  } __attribute__((packed));
> 
> 
> -extern int totemip_equal(struct totem_ip_address *addr1, struct 
> totem_ip_address *addr2);
> +extern int totemip_equal(const struct totem_ip_address *addr1,
> +                      const struct totem_ip_address *addr2);
>  extern int totemip_compare(const void *a, const void *b);
> -extern void totemip_copy(struct totem_ip_address *addr1, struct 
> totem_ip_address *addr2);
> -extern void totemip_copy_endian_convert(struct totem_ip_address *addr1, 
> struct totem_ip_address *addr2);
> +extern void totemip_copy(struct totem_ip_address *addr1,
> +                      const struct totem_ip_address *addr2);
> +extern void totemip_copy_endian_convert(struct totem_ip_address *addr1,
> +                                     const struct totem_ip_address *addr2);
>  int totemip_localhost(int family, struct totem_ip_address *localhost);
> -extern int totemip_localhost_check(struct totem_ip_address *addr);
> +extern int totemip_localhost_check(const struct totem_ip_address *addr);
>  extern const char *totemip_print(const struct totem_ip_address *addr);
> -extern int totemip_sockaddr_to_totemip_convert(struct sockaddr_storage 
> *saddr, struct totem_ip_address *ip_addr);
> +extern int totemip_sockaddr_to_totemip_convert(const struct sockaddr_storage 
> *saddr,
> +                                            struct totem_ip_address 
> *ip_addr);
>  extern int totemip_totemip_to_sockaddr_convert(struct totem_ip_address 
> *ip_addr,
>                                              uint16_t port, struct 
> sockaddr_storage *saddr, int *addrlen);
>  extern int totemip_parse(struct totem_ip_address *totemip, const char *addr,
>                        int family);
> -extern int totemip_iface_check(struct totem_ip_address *bindnet, struct 
> totem_ip_address *boundto, int *interface_up, int *interface_num, int 
> mask_high_bit);
> +extern int totemip_iface_check(struct totem_ip_address *bindnet,
> +                            struct totem_ip_address *boundto,
> +                            int *interface_up,
> +                            int *interface_num,
> +                            int mask_high_bit);
> 
>  /* These two simulate a zero in_addr by clearing the family field */
>  static inline void totemip_zero_set(struct totem_ip_address *addr)
>  {
>       addr->family = 0;
>  }
> -static inline int totemip_zero_check(struct totem_ip_address *addr)
> +static inline int totemip_zero_check(const struct totem_ip_address *addr)
>  {
>       return (addr->family == 0);
>  }

_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to