Changeset 4b5d05b46785f944e0d4ba506afeb9df499a6aac

Show
Ignore:
Timestamp:
06/21/11 11:08:58 (11 months ago)
Author:
Neutron Soutmun <neo.neutron@…>
Children:
0689196636498f5ef2219550ec79bf0f7c40aa41
Parents:
cb5371333692435b9818b9043a26980e404202d1
git-committer:
Neutron Soutmun <neo.neutron@…> (06/21/11 11:08:58)
Message:

Fix compiler warnings

  • src/rahunasd.c:
    • Declare termstring = "" instead.
  • src/rh-ipset.{h, c}:
    • Declare unsigned variable as unsigned int instead.
  • src/rh-ipset.c (set_ipiphash_adtip):
    • Fix typo which should call set_ipiphash_adtip_nb() instead.
  • src/rh-serviceclass.c, src/rh-task-serviceclass.c:
    • Include string.h to fix the compiler warnings.
  • src/rh-serviceclass.{h,c}:
    • Replace struct main_server and struct serviceclass with RHMainServer and RHSvClass respectively.
  • src/rh-task-ipset.c (set_cleanup):
    • Fix wrong type casting.
  • src/rh-task-memset.c (startsess):
    • Fix compiler warnnings on assigning "const char *" to "char *" variable.
  • src/rh-task-serviceclass.c:
    • Fix compiler warnnings on rh_free().
    • Free member->mapping_ip before assign new data.
  • src/Makefile.am:
    • Add src/ipset/*.h headers to makefile which they should included in tarball.
Location:
src
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • src/Makefile.am

    rcb53713 r4b5d05b  
    2929  rh-xmlrpc-cmd.c \ 
    3030  rh-xmlrpc-cmd.h \ 
     31  ipset/ip_set_bitmaps.h \ 
     32  ipset/ip_set_hashes.h \ 
     33  ipset/ip_set_rahunas_ipiphash.h \ 
     34  ipset/ip_set.h \ 
     35  ipset/ip_set_rahunas.h \ 
    3136  rh-ipset.c \ 
    3237  rh-ipset.h \ 
  • src/rahunasd.c

    rcb53713 r4b5d05b  
    2424#include "rh-task.h" 
    2525 
    26 const char *termstring = '\0'; 
     26const char *termstring = ""; 
    2727pid_t pid, sid; 
    2828 
  • src/rh-ipset.c

    rcb53713 r4b5d05b  
    8686} 
    8787 
    88 int kernel_sendto_handleerrno(unsigned op, void *data, socklen_t size) 
     88int kernel_sendto_handleerrno(unsigned int op, void *data, socklen_t size) 
    8989{ 
    9090  int res = wrapped_setsockopt(data, size); 
     
    230230 
    231231int set_adtip(struct set *rahunas_set, const char *adtip, const char *adtmac,  
    232               unsigned op) 
     232              unsigned int op) 
    233233{ 
    234234  ip_set_ip_t ip; 
     
    241241 
    242242int set_adtip_nb(struct set *rahunas_set, ip_set_ip_t *adtip,  
    243                  unsigned char adtmac[ETH_ALEN], unsigned op) 
     243                 unsigned char adtmac[ETH_ALEN], unsigned int op) 
    244244{ 
    245245  struct ip_set_req_adt *req_adt = NULL; 
     
    300300 
    301301int set_ipiphash_adtip(struct set *rahunas_set, const char *ip, 
    302                        const char *ip1, unsigned op) 
     302                       const char *ip1, unsigned int op) 
    303303{ 
    304304  ip_set_ip_t _ip; 
     
    307307  parse_ip(ip1, &_ip1); 
    308308 
    309   return set_adtip_nb(rahunas_set, &_ip, &_ip1, op); 
     309  return set_ipiphash_adtip_nb(rahunas_set, &_ip, &_ip1, op); 
    310310} 
    311311 
    312312int set_ipiphash_adtip_nb(struct set *rahunas_set, ip_set_ip_t *ip, 
    313                           ip_set_ip_t *ip1, unsigned op) 
     313                          ip_set_ip_t *ip1, unsigned int op) 
    314314{ 
    315315  struct ip_set_req_adt *req_adt = NULL; 
     
    384384size_t load_set_list(RHVServer *vs, const char name[IP_SET_MAXNAMELEN], 
    385385          ip_set_id_t *idx, 
    386           unsigned op, unsigned cmd) 
     386          unsigned int op, unsigned int cmd) 
    387387{ 
    388388  void *data = NULL; 
  • src/rh-ipset.h

    rcb53713 r4b5d05b  
    2424  ip_set_id_t id;       /* Unique set id */ 
    2525  ip_set_id_t index;      /* Array index */ 
    26   unsigned ref;       /* References in kernel */ 
     26  unsigned int ref;       /* References in kernel */ 
    2727  struct settype *settype;    /* Pointer to set type functions */ 
    2828}; 
     
    7575int wrapped_setsockopt(void *data, socklen_t size); 
    7676void kernel_getfrom(void *data, socklen_t * size); 
    77 int kernel_sendto_handleerrno(unsigned op, void *data, socklen_t size); 
     77int kernel_sendto_handleerrno(unsigned int op, void *data, socklen_t size); 
    7878void kernel_sendto(void *data, size_t size); 
    7979int kernel_getfrom_handleerrno(void *data, socklen_t * size); 
    8080struct set *set_adt_get(const char *name); 
    8181int set_adtip(struct set *rahunas_set, const char *adtip, const char *adtmac,  
    82               unsigned op); 
     82              unsigned int op); 
    8383 
    8484int set_adtip_nb(struct set *rahunas_set, ip_set_ip_t *adtip,  
    85                  unsigned char adtmac[ETH_ALEN], unsigned op); 
     85                 unsigned char adtmac[ETH_ALEN], unsigned int op); 
    8686 
    8787int set_ipiphash_adtip(struct set *rahunas_set, const char *ip, 
    88                        const char *ip1, unsigned op); 
     88                       const char *ip1, unsigned int op); 
    8989int set_ipiphash_adtip_nb(struct set *rahunas_set, ip_set_ip_t *ip, 
    90                           ip_set_ip_t *ip1, unsigned op); 
     90                          ip_set_ip_t *ip1, unsigned int op); 
    9191 
    9292void set_flush(const char *name); 
     
    9494size_t load_set_list(RHVServer *vs, const char name[IP_SET_MAXNAMELEN], 
    9595          ip_set_id_t *idx, 
    96           unsigned op, unsigned cmd); 
     96          unsigned int op, unsigned int cmd); 
    9797 
    9898int get_header_from_set (RHVServer *vs); 
  • src/rh-serviceclass.c

    r43154f8 r4b5d05b  
    55 */ 
    66#include <stdio.h> 
     7#include <string.h> 
    78#include <arpa/inet.h> 
    89#include "rahunasd.h" 
     
    1112#include "rh-ipset.h" 
    1213 
    13 int serviceclass_do_init (struct main_server *ms, struct serviceclass *sc); 
    14  
    15 struct serviceclass *serviceclass_exists(GList *serviceclass_list, 
     14int serviceclass_do_init (RHMainServer *ms, RHSvClass *sc); 
     15 
     16RHSvClass *serviceclass_exists(GList *serviceclass_list, 
    1617                                         int serviceclass_id, 
    1718                                         const char *serviceclass_name) 
    1819{ 
    1920  GList *runner = g_list_first(serviceclass_list); 
    20   struct serviceclass *lserviceclass = NULL; 
    21  
    22   while (runner != NULL) { 
    23     lserviceclass = (struct serviceclass *)runner->data; 
     21  RHSvClass *lserviceclass = NULL; 
     22 
     23  while (runner != NULL) { 
     24    lserviceclass = (RHSvClass *)runner->data; 
    2425 
    2526    if (lserviceclass->serviceclass_config->serviceclass_id == serviceclass_id) 
     
    3536} 
    3637 
    37 struct servicclass *serviceclass_get_by_id(struct main_server *ms, 
    38                                            int search_id) 
     38RHSvClass *serviceclass_get_by_id(RHMainServer *ms, int search_id) 
    3939{ 
    4040  GList *runner = g_list_first(ms->serviceclass_list); 
    41   struct serviceclass *lserviceclass = NULL; 
    42  
    43   while (runner != NULL) { 
    44     lserviceclass = (struct serviceclass *)runner->data; 
     41  RHSvClass *lserviceclass = NULL; 
     42 
     43  while (runner != NULL) { 
     44    lserviceclass = (RHSvClass *)runner->data; 
    4545 
    4646    if (lserviceclass->serviceclass_config->serviceclass_id == search_id) { 
     
    5353} 
    5454 
    55 int serviceclass_cleanup(struct serviceclass *sc) 
     55int serviceclass_cleanup(RHSvClass *sc) 
    5656{ 
    5757  if (sc == NULL) 
     
    6464} 
    6565 
    66 int register_serviceclass(struct main_server *ms, 
     66int register_serviceclass(RHMainServer *ms, 
    6767                          const char *serviceclass_cfg_file) 
    6868{ 
     
    7373  union rahunas_config *cfg_get = NULL; 
    7474  struct rahunas_serviceclass_config *serviceclass_config = NULL; 
    75   struct serviceclass *new_serviceclass = NULL; 
    76   struct serviceclass *old_serviceclass = NULL; 
     75  RHSvClass *new_serviceclass = NULL; 
     76  RHSvClass *old_serviceclass = NULL; 
    7777 
    7878  union rahunas_config config = { 
     
    9999      if (old_serviceclass->dummy_config != NULL) { 
    100100        DP("Cleanup old dummy config"); 
    101         rh_free(&old_serviceclass->dummy_config); 
     101        rh_free((void **) &old_serviceclass->dummy_config); 
    102102      } 
    103103 
     
    134134  memcpy(serviceclass_config, &config, sizeof(struct rahunas_serviceclass_config)); 
    135135 
    136   new_serviceclass = (struct serviceclass *) rh_malloc(sizeof(struct serviceclass)); 
     136  new_serviceclass = (RHSvClass *) rh_malloc(sizeof(RHSvClass)); 
    137137 
    138138  if (new_serviceclass == NULL) 
    139139    return -1; 
    140140 
    141   memset(new_serviceclass, 0, sizeof(struct serviceclass)); 
     141  memset(new_serviceclass, 0, sizeof(RHSvClass)); 
    142142 
    143143  new_serviceclass->serviceclass_config = serviceclass_config; 
     
    148148} 
    149149 
    150 int unregister_serviceclass(struct main_server *ms, int serviceclass_id) 
    151 { 
    152   GList *serviceclass_list = ms->serviceclass_list; 
    153   GList *runner = g_list_first(serviceclass_list); 
    154   struct serviceclass *lserviceclass = NULL; 
    155  
    156   while (runner != NULL) { 
    157     lserviceclass = (struct serviceclass *)runner->data; 
     150int unregister_serviceclass(RHMainServer *ms, int serviceclass_id) 
     151{ 
     152  GList *serviceclass_list = ms->serviceclass_list; 
     153  GList *runner = g_list_first(serviceclass_list); 
     154  RHSvClass *lserviceclass = NULL; 
     155 
     156  while (runner != NULL) { 
     157    lserviceclass = (RHSvClass *)runner->data; 
    158158    if (lserviceclass->serviceclass_config->serviceclass_id == serviceclass_id) { 
    159159      serviceclass_cleanup(lserviceclass); 
     
    168168} 
    169169 
    170 int unregister_serviceclass_all(struct main_server *ms) 
     170int unregister_serviceclass_all(RHMainServer *ms) 
    171171{ 
    172172  GList *serviceclass_list = ms->serviceclass_list; 
    173173  GList *runner = g_list_first(serviceclass_list); 
    174174  GList *deleting = NULL; 
    175   struct serviceclass *lserviceclass = NULL; 
    176  
    177   while (runner != NULL) { 
    178     lserviceclass = (struct serviceclass *)runner->data; 
     175  RHSvClass *lserviceclass = NULL; 
     176 
     177  while (runner != NULL) { 
     178    lserviceclass = (RHSvClass *)runner->data; 
    179179    serviceclass_cleanup(lserviceclass); 
    180180    deleting = runner; 
     
    188188} 
    189189 
    190 int walk_through_serviceclass(int (*callback)(void *, void *), struct main_server *ms) 
    191 { 
    192   GList *serviceclass_list = ms->serviceclass_list; 
    193   GList *runner = g_list_first(serviceclass_list); 
    194   struct serviceclass *sc = NULL; 
    195  
    196   while (runner != NULL) { 
    197     sc = (struct serviceclass *)runner->data; 
     190int walk_through_serviceclass(int (*callback)(void *, void *), RHMainServer *ms) 
     191{ 
     192  GList *serviceclass_list = ms->serviceclass_list; 
     193  GList *runner = g_list_first(serviceclass_list); 
     194  RHSvClass *sc = NULL; 
     195 
     196  while (runner != NULL) { 
     197    sc = (RHSvClass *)runner->data; 
    198198 
    199199    (*callback)(ms, sc); 
     
    205205} 
    206206 
    207 void serviceclass_init(struct main_server *ms, struct serviceclass *sc) 
     207void serviceclass_init(RHMainServer *ms, RHSvClass *sc) 
    208208{ 
    209209  struct rahunas_serviceclass_config *sc_config = NULL; 
     
    221221} 
    222222 
    223 void serviceclass_reload(struct main_server *ms, struct serviceclass *sc) 
     223void serviceclass_reload(RHMainServer *ms, RHSvClass *sc) 
    224224{ 
    225225  if (sc->serviceclass_config->init_flag == SC_DONE) { 
     
    257257        memcpy(sc->serviceclass_config, sc->dummy_config, 
    258258          sizeof(struct rahunas_serviceclass_config)); 
    259         rh_free(&sc->dummy_config); 
     259        rh_free((void **) &sc->dummy_config); 
    260260      } 
    261261 
     
    269269 
    270270 
    271 void serviceclass_unused_cleanup(struct main_server *ms) 
    272 { 
    273   GList *serviceclass_list = ms->serviceclass_list; 
    274   GList *runner = g_list_first(serviceclass_list); 
    275   struct serviceclass *lserviceclass = NULL; 
    276  
    277   while (runner != NULL) { 
    278     lserviceclass = (struct serviceclass *)runner->data; 
     271void serviceclass_unused_cleanup(RHMainServer *ms) 
     272{ 
     273  GList *serviceclass_list = ms->serviceclass_list; 
     274  GList *runner = g_list_first(serviceclass_list); 
     275  RHSvClass *lserviceclass = NULL; 
     276 
     277  while (runner != NULL) { 
     278    lserviceclass = (RHSvClass *)runner->data; 
    279279    if (lserviceclass->serviceclass_config->init_flag == SC_NONE) { 
    280280      logmsg(RH_LOG_NORMAL, "[%s] - Service class config removed", 
     
    290290} 
    291291 
    292 int serviceclass_do_init (struct main_server *ms, struct serviceclass *sc) 
     292int serviceclass_do_init (RHMainServer *ms, RHSvClass *sc) 
    293293{ 
    294294  struct rahunas_serviceclass_config *sc_config = sc->serviceclass_config; 
  • src/rh-serviceclass.h

    rcb53713 r4b5d05b  
    88 
    99#include <glib.h> 
     10#include "rh-server.h" 
    1011#include "rh-config.h" 
    1112 
     
    2021 
    2122 
    22 struct serviceclass *serviceclass_exists(GList *serviceclass_list, 
    23                                          int serviceclass_id, 
    24                                          const char *servicclass_name); 
     23RHSvClass *serviceclass_exists    (GList *serviceclass_list, 
     24                                   int serviceclass_id, 
     25                                   const char *serviceclass_name); 
    2526 
    26 struct servicclass *serviceclass_get_by_id(struct main_server *ms, 
    27                                            int search_id); 
    28 int serviceclass_cleanup(struct serviceclass *sc); 
     27RHSvClass *serviceclass_get_by_id (RHMainServer *ms, int search_id); 
     28int serviceclass_cleanup          (RHSvClass *sc); 
    2929 
    30 int register_serviceclass(struct main_server *ms, 
    31                           const char *serviceclass_cfg_file); 
    32 int unregister_serviceclass(struct main_server *ms, int serviceclass_id); 
    33 int unregister_serviceclass_all(struct main_server *ms); 
     30int register_serviceclass         (RHMainServer *ms, 
     31                                   const char *serviceclass_cfg_file); 
     32int unregister_serviceclass       (RHMainServer *ms, int serviceclass_id); 
     33int unregister_serviceclass_all   (RHMainServer *ms); 
    3434 
    35 void serviceclass_init(struct main_server *ms, struct serviceclass *sc); 
    36 void serviceclass_reload(struct main_server *ms, struct serviceclass *sc); 
    37 void serviceclass_unused_cleanup(struct main_server *ms); 
     35void serviceclass_init            (RHMainServer *ms, RHSvClass *sc); 
     36void serviceclass_reload          (RHMainServer *ms, RHSvClass *sc); 
     37void serviceclass_unused_cleanup  (RHMainServer *ms); 
    3838 
    3939#endif // __RH_SERVICECLASS_H 
  • src/rh-task-ipset.c

    rcb53713 r4b5d05b  
    3232 
    3333  offset = sizeof(struct ip_set_list) + setlist->header_size; 
    34   table = (struct ip_set_rahunas *)(process->list + offset); 
     34  table = (struct ip_set_rahu *)(process->list + offset); 
    3535 
    3636  while (runner != NULL) { 
  • src/rh-task-memset.c

    rcb53713 r4b5d05b  
    155155    free(member->serviceclass_name); 
    156156 
    157   if (member->mapping_ip && member->mapping_ip != termstring) 
    158     free(member->mapping_ip); 
     157  if (member->mapping_ip) 
     158    { 
     159      free(member->mapping_ip); 
     160      member->mapping_ip = NULL; 
     161    } 
    159162 
    160163  member->username   = strdup(req->username); 
     
    169172  member->serviceclass_description = termstring; 
    170173  member->serviceclass_slot_id = 0; 
    171   member->mapping_ip = termstring; 
     174  member->mapping_ip = strdup(termstring); 
    172175 
    173176  if (req->session_start == 0) { 
  • src/rh-task-serviceclass.c

    rcb53713 r4b5d05b  
    55 */ 
    66 
     7#include <string.h> 
    78#include <syslog.h> 
    89#include <libgda/libgda.h> 
     
    8687    logmsg(RH_LOG_NORMAL, "Service Class: Flushing set ..."); 
    8788    set_flush (SERVICECLASS_SET_NAME); 
    88     rh_free(&rh_serviceclass_set); 
     89    rh_free((void **) &rh_serviceclass_set); 
    8990  } 
    9091 
     
    160161    member->serviceclass_description = sc_config->description; 
    161162    member->serviceclass_slot_id = req->serviceclass_slot_id; 
     163 
     164    if (member->mapping_ip) 
     165      { 
     166        free (member->mapping_ip); 
     167        member->mapping_ip = NULL; 
     168      } 
    162169 
    163170    member->mapping_ip = strdup (ip_tostring(ip1));