Explorar o código

Merge branch 'maint'

* maint:
  Make set_user() param const
Bryan Drewery %!s(int64=6) %!d(string=hai) anos
pai
achega
5f33034232
Modificáronse 5 ficheiros con 14 adicións e 10 borrados
  1. 1 1
      src/cmds.cc
  2. 1 1
      src/mod/share.mod/share.cc
  3. 8 4
      src/userent.cc
  4. 3 3
      src/userrec.cc
  5. 1 1
      src/users.h

+ 1 - 1
src/cmds.cc

@@ -4003,7 +4003,7 @@ static void cmd_clearhosts(int idx, char *par)
   if (get_user(&USERENTRY_HOSTS, u2)) {
     shareout("ch %s\n", handle);
     noshare = 1;
-    set_user(&USERENTRY_HOSTS, u2, (void *) "none");
+    set_user(&USERENTRY_HOSTS, u2, "none");
     noshare = 0;
     dprintf(idx, "Cleared hosts for %s.\n", handle);
     if (!conf.bot->hub && server_online)

+ 1 - 1
src/mod/share.mod/share.cc

@@ -698,7 +698,7 @@ share_clearhosts(int idx, char *par)
       if (!conf.bot->hub && server_online)
         check_this_user(u->handle, 1, NULL);
       noshare = 1;
-      set_user(&USERENTRY_HOSTS, u, (void *) "none");
+      set_user(&USERENTRY_HOSTS, u, "none");
       noshare = 0;
     }
   }

+ 8 - 4
src/userent.cc

@@ -114,7 +114,7 @@ def_get(struct userrec *u, struct user_entry *e)
   return e->u.string;
 }
 
-bool def_set_real(struct userrec *u, struct user_entry *e, void *buf, bool protect)
+static bool def_set_real(struct userrec *u, struct user_entry *e, void *buf, bool protect)
 {
   char *string = (char *) buf;
 
@@ -158,7 +158,7 @@ bool def_set(struct userrec *u, struct user_entry *e, void *buf)
   return (def_set_real(u, e, buf, 0));
 }
 
-bool set_protected(struct userrec *u, struct user_entry *e, void *buf)
+static bool set_protected(struct userrec *u, struct user_entry *e, void *buf)
 {
   return (def_set_real(u, e, buf, 1));
 }
@@ -1105,7 +1105,7 @@ void *get_user(struct user_entry_type *et, struct userrec *u)
   return NULL;
 }
 
-bool set_user(struct user_entry_type *et, struct userrec *u, void *d)
+bool set_user(struct user_entry_type *et, struct userrec *u, const void *d)
 {
   if (!u || !et)
     return 0;
@@ -1121,7 +1121,11 @@ bool set_user(struct user_entry_type *et, struct userrec *u, void *d)
     e->u.list = NULL;
     list_insert((&(u->entries)), e);
   }
-  r = et->set(u, e, d);
+  /*
+   * d is typically having its ownership passed down except for simple strings
+   * which will be copied.
+   */
+  r = et->set(u, e, (void*)d);
   if (!e->u.list) {
     list_delete((struct list_type **) &(u->entries), (struct list_type *) e);
     free(e);

+ 3 - 3
src/userrec.cc

@@ -669,8 +669,8 @@ struct userrec *adduser(struct userrec *bu, const char *handle,
   } else {
     u->flags = default_flags;
   }
-  set_user(&USERENTRY_PASS, u, (void*)pass);/* XXX: const */
-  set_user(&USERENTRY_HOSTS, u, (void*)host);
+  set_user(&USERENTRY_PASS, u, pass);
+  set_user(&USERENTRY_HOSTS, u, host);
   if (bu == userlist)
     clear_chanlist();
   noshare = oldshare;
@@ -820,7 +820,7 @@ int delhost_by_handle(char *handle, char *host)
     }
   }
   if (!qprev)
-    set_user(&USERENTRY_HOSTS, u, (void *) "none");
+    set_user(&USERENTRY_HOSTS, u, "none");
   if (!noshare && i)
     shareout("-h %s %s\n", handle, host);
   clear_chanlist();

+ 1 - 1
src/users.h

@@ -125,7 +125,7 @@ struct user_entry *find_user_entry(struct user_entry_type *, struct userrec *);
 void *get_user(struct user_entry_type *, struct userrec *);
 bool user_has_host(const char *, struct userrec *, char *);
 bool user_has_matching_host(const char *handle, struct userrec *u, char *host);
-bool set_user(struct user_entry_type *, struct userrec *, void *);
+bool set_user(struct user_entry_type *, struct userrec *, const void *);
 
 #define is_bot(u)	((u) && (u)->bot)