[hipl-commit] [trunk] Rev 4546: Add the "write-strings" warning CFLAG.

  • From: Mircea Gherzan <mircea.gherzan@xxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Mon, 17 May 2010 21:30:26 +0300

Committer: Mircea Gherzan <mircea.gherzan@xxxxxxxxxxxxxx>
Date: 17/05/2010 at 21:30:26
Revision: 4546
Revision-id: mircea.gherzan@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  Add the "write-strings" warning CFLAG.

Modified:
  M  configure.ac
  M  firewall/firewall.c
  M  firewall/helpers.c
  M  firewall/helpers.h
  M  firewall/lsi.c
  M  firewall/pisa_cert.c
  M  hipd/cert.c
  M  hipd/hidb.c
  M  hipd/input.c
  M  hipd/netdev.c
  M  hipd/nsupdate.c
  M  lib/core/builder.c
  M  lib/core/builder.h
  M  lib/core/capability.c
  M  lib/core/certtools.c
  M  lib/core/certtools.h
  M  lib/core/conf.c
  M  lib/core/debug.c
  M  lib/core/filemanip.c
  M  lib/core/filemanip.h
  M  lib/opphip/wrap.c
  M  lib/tool/nlink.c
  M  lib/tool/nlink.h
  M  lib/tool/xfrmapi.c

=== modified file 'configure.ac'
--- configure.ac        2010-05-17 16:55:10 +0000
+++ configure.ac        2010-05-17 18:24:10 +0000
@@ -66,7 +66,7 @@
 
 
 # Set default AM_CFLAGS for the complete project.
-AC_SUBST(AM_CFLAGS, "-std=c99 -Werror -Wall -Wredundant-decls 
-Wdisabled-optimization -Wundef -Wstrict-prototypes -Wmissing-prototypes 
-Wno-deprecated-declarations -Wpointer-arith -fno-strict-aliasing")
+AC_SUBST(AM_CFLAGS, "-std=c99 -Werror -Wall -Wredundant-decls 
-Wdisabled-optimization -Wundef -Wstrict-prototypes -Wmissing-prototypes 
-Wno-deprecated-declarations -Wpointer-arith -Wwrite-strings 
-fno-strict-aliasing")
 
 # Set the preprocessor flags for the entire project
 AC_SUBST(AM_CPPFLAGS, "-D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=500")

=== modified file 'firewall/firewall.c'
--- firewall/firewall.c 2010-05-12 10:09:10 +0000
+++ firewall/firewall.c 2010-05-17 18:24:10 +0000
@@ -848,7 +848,7 @@
     int count, err, status;
     char cmd[40];
     int mod_total;
-    char *mod_name[] =
+    const char *mod_name[] =
     { "ip_queue", "ip6_queue", "iptable_filter", "ip6table_filter" };
 
     mod_total = sizeof(mod_name) / sizeof(char *);

=== modified file 'firewall/helpers.c'
--- firewall/helpers.c  2010-03-18 21:15:21 +0000
+++ firewall/helpers.c  2010-05-17 18:24:10 +0000
@@ -63,7 +63,7 @@
  *                command does not contain malicious
  *                code.
  */
-void system_print(char *command)
+void system_print(const char *command)
 {
     if (system(command) == -1) {
         HIP_ERROR("Could not execute system command %s", command);

=== modified file 'firewall/helpers.h'
--- firewall/helpers.h  2010-04-22 10:12:54 +0000
+++ firewall/helpers.h  2010-05-17 18:24:10 +0000
@@ -15,6 +15,6 @@
 
 char *addr_to_numeric(const struct in6_addr *addrp);
 struct in6_addr *numeric_to_addr(const char *num);
-void system_print(char *command);
+void system_print(const char *command);
 
 #endif /* HIP_FIREWALL_HELPERS_H */

=== modified file 'firewall/lsi.c'
--- firewall/lsi.c      2010-04-15 20:47:19 +0000
+++ firewall/lsi.c      2010-05-17 18:24:10 +0000
@@ -38,6 +38,8 @@
 
 #define BUFSIZE HIP_MAX_PACKET
 
+#define PROTO_STRING_MAX    16
+
 /**
  * build a message for hipd to trigger a base exchange
  *
@@ -253,9 +255,9 @@
     int ip_hdr_size                            = 0;
     int portDest                               = 0;
     int process_as_lsi                         = 0;
-    char *proto                                = NULL;
     hip_lsi_t lsi_our                          = {0};
     hip_lsi_t lsi_peer                         = {0};
+    char proto[PROTO_STRING_MAX];
     struct in6_addr src_addr, dst_addr;
     struct in_addr src_v4, dst_v4;
     struct ip6_hdr *ip6_hdr                    = (struct ip6_hdr *) m->payload;
@@ -266,11 +268,11 @@
     switch (ip6_hdr->ip6_nxt) {
     case IPPROTO_UDP:
         portDest = ((struct udphdr *) ((m->payload) + ip_hdr_size))->dest;
-        proto    = "udp6";
+        strcpy(proto, "udp6");
         break;
     case IPPROTO_TCP:
         portDest = ((struct tcphdr *) ((m->payload) + ip_hdr_size))->dest;
-        proto    = "tcp6";
+        strcpy(proto, "tcp6");
         break;
     case IPPROTO_ICMPV6:
         HIP_DEBUG("ICMPv6 packet\n");

=== modified file 'firewall/pisa_cert.c'
--- firewall/pisa_cert.c        2010-04-09 16:24:44 +0000
+++ firewall/pisa_cert.c        2010-05-17 18:24:10 +0000
@@ -30,7 +30,7 @@
  * @param size size of the buffer result
  * @return 0 on success
  */
-static char *pisa_cert_get_part(char *cert, char *name, char *r, size_t size)
+static char *pisa_cert_get_part(char *cert, const char *name, char *r, size_t 
size)
 {
     int level = 0, len = 0;
     char *p   = cert, *start = NULL;
@@ -113,7 +113,7 @@
  * @param size size of the buffer result
  * @return 0 on success
  */
-static void pisa_cert_get_content(char *cert, char *name, char *r, size_t size)
+static void pisa_cert_get_content(char *cert, const char *name, char *r, 
size_t size)
 {
     char *start = cert;
     int len     = 0;

=== modified file 'hipd/cert.c'
--- hipd/cert.c 2010-04-16 18:45:44 +0000
+++ hipd/cert.c 2010-05-17 18:24:10 +0000
@@ -949,15 +949,15 @@
          * hash to the X509_EXT_conf it knows what to do with it */
 
         HIP_IFEL(!(ext = X509V3_EXT_conf(NULL, &ctx,
-                                         "basicConstraints",
-                                         "CA:true")), -1,
+                                         (char *)"basicConstraints",
+                                         (char *)"CA:true")), -1,
                  "Failed to create extension\n");
         HIP_IFEL((!X509_add_ext(cert, ext, -1)), -1,
                  "Failed to add extensions to the cert\n");
 
         HIP_IFEL(!(ext = X509V3_EXT_conf(NULL, &ctx,
-                                         "subjectKeyIdentifier",
-                                         "hash")), -1,
+                                         (char *)"subjectKeyIdentifier",
+                                         (char *)"hash")), -1,
                  "Failed to create extension\n");
         HIP_IFEL((!X509_add_ext(cert, ext, -1)), -1,
                  "Failed to add extensions to the cert\n");
@@ -966,7 +966,7 @@
     /* add subjectAltName = IP:<HIT> */
     sprintf(ialtname, "IP:%s", issuer_hit);
     HIP_IFEL(!(ext = X509V3_EXT_conf(NULL, &ctx,
-                                     "issuerAltName",
+                                     (char *)"issuerAltName",
                                      ialtname)), -1,
              "Failed to create extension\n");
     HIP_IFEL((!X509_add_ext(cert, ext, -1)), -1,
@@ -974,7 +974,7 @@
     /* add subjectAltName = IP:<HIT> */
     sprintf(saltname, "IP:%s", subject_hit);
     HIP_IFEL(!(ext = X509V3_EXT_conf(NULL, &ctx,
-                                     "subjectAltName",
+                                     (char *)"subjectAltName",
                                      saltname)), -1,
              "Failed to create extension\n");
     HIP_IFEL((!X509_add_ext(cert, ext, -1)), -1,

=== modified file 'hipd/hidb.c'
--- hipd/hidb.c 2010-04-21 15:18:19 +0000
+++ hipd/hidb.c 2010-05-17 18:24:10 +0000
@@ -24,7 +24,7 @@
 HIP_HASHTABLE *hip_local_hostid_db = NULL;
 #define HIP_MAX_HOST_ID_LEN 1600
 
-static char *lsi_addresses[] = {"1.0.0.1", "1.0.0.2", "1.0.0.3", "1.0.0.4"};
+static const char *lsi_addresses[] = {"1.0.0.1", "1.0.0.2", "1.0.0.3", 
"1.0.0.4"};
 
 static int hip_add_host_id(HIP_HASHTABLE *db,
                            const struct hip_lhi *lhi,

=== modified file 'hipd/input.c'
--- hipd/input.c        2010-05-17 16:55:10 +0000
+++ hipd/input.c        2010-05-17 18:24:10 +0000
@@ -1429,7 +1429,7 @@
      */
     if (!hip_blind_get_status()) {
         /* Everything ok, save host id to HA */
-        char *str = NULL;
+        const char *str = NULL;
         int len;
         HIP_IFE(hip_get_param_host_id_di_type_len(
                     peer_host_id, &str, &len) < 0, -1);

=== modified file 'hipd/netdev.c'
--- hipd/netdev.c       2010-05-17 14:56:20 +0000
+++ hipd/netdev.c       2010-05-17 18:24:10 +0000
@@ -49,6 +49,9 @@
 #define FA_IGNORE 0
 #define FA_ADD 1
 
+/** Maximum lenght of the address family string */
+#define FAM_STR_MAX               32
+
 /**
  * This is the white list. For every interface, which is in our white list,
  * this array has a fixed size, because there seems to be no need at this
@@ -528,20 +531,21 @@
 
 #ifdef CONFIG_HIP_DEBUG /* Debug block. */
     {
-        char ipv6_str[INET6_ADDRSTRLEN], *fam_str = NULL;
+        char ipv6_str[INET6_ADDRSTRLEN];
+        char fam_str[FAM_STR_MAX];
 
         if (addr->sa_family == AF_INET6) {
-            fam_str = "AF_INET6";
+            strncpy(fam_str, "AF_INET6", FAM_STR_MAX);
             inet_ntop(AF_INET6,
                       &(((struct sockaddr_in6 *) (void *) addr)->sin6_addr),
                       ipv6_str, INET6_ADDRSTRLEN);
         } else if (addr->sa_family == AF_INET) {
-            fam_str = "AF_INET";
+            strncpy(fam_str, "AF_INET", FAM_STR_MAX);
             inet_ntop(AF_INET,
                       &(((struct sockaddr_in *) (void *) addr)->sin_addr),
                       ipv6_str, INET6_ADDRSTRLEN);
         } else {
-            fam_str = "not AF_INET or AF_INET6";
+            strncpy(fam_str, "not AF_INET or AF_INET6", FAM_STR_MAX);
             memset(ipv6_str, 0, INET6_ADDRSTRLEN);
         }
 

=== modified file 'hipd/nsupdate.c'
--- hipd/nsupdate.c     2010-05-12 13:55:00 +0000
+++ hipd/nsupdate.c     2010-05-17 18:24:10 +0000
@@ -80,7 +80,7 @@
  * @return          newly allocated string with result or NULL in case of error
  */
 
-static char *make_env(char *name, char *value)
+static char *make_env(const char *name, char *value)
 {
     char *result = NULL;
     int err      = 0;
@@ -212,11 +212,11 @@
         char *env_hit   = make_env(VAR_HIT, hit);
         char *env_start = make_env(VAR_START, start_str);
 
-        char *cmd[]     = { NSUPDATE_ARG0, NULL };
-        char *env[]     = { env_ips, env_hit, env_start, NULL };
+        const char *cmd[]     = { NSUPDATE_ARG0, NULL };
+        char *const env[]     = { env_ips, env_hit, env_start, NULL };
 
         HIP_DEBUG("Executing %s with %s; %s; %s\n", NSUPDATE_PL, env_hit, 
env_ips, env_start);
-        execve(NSUPDATE_PL, cmd, env);
+        execve(NSUPDATE_PL, (char **) cmd, env);
 
         if (env_ips) {
             free(env_ips);

=== modified file 'lib/core/builder.c'
--- lib/core/builder.c  2010-05-17 16:55:10 +0000
+++ lib/core/builder.c  2010-05-17 18:24:10 +0000
@@ -1120,7 +1120,7 @@
  * @param msg_type message type number
  * @return the name of the message type
  */
-char *hip_message_type_name(const uint8_t msg_type)
+const char *hip_message_type_name(const uint8_t msg_type)
 {
     switch (msg_type) {
     case HIP_I1:            return "HIP_I1";
@@ -1222,7 +1222,7 @@
  * @param param_type parameter type number
  * @return      name of the message type
  */
-char *hip_param_type_name(const hip_tlv_type_t param_type)
+const char *hip_param_type_name(const hip_tlv_type_t param_type)
 {
     switch (param_type) {
     case HIP_PARAM_ACK:             return "HIP_PARAM_ACK";
@@ -3508,11 +3508,11 @@
  * @return zero on success and negative on error
  */
 int hip_get_param_host_id_di_type_len(struct hip_host_id *host,
-                                      char **id,
+                                      const char **id,
                                       int *len)
 {
     int type;
-    static char *debuglist[3] = {"none", "FQDN", "NAI"};
+    static const char *debuglist[3] = {"none", "FQDN", "NAI"};
 
     type = ntohs(host->di_type_length);
     *len = type & 0x0FFF;

=== modified file 'lib/core/builder.h'
--- lib/core/builder.h  2010-05-16 17:58:14 +0000
+++ lib/core/builder.h  2010-05-17 18:24:10 +0000
@@ -193,18 +193,18 @@
 void *hip_get_param_contents(const struct hip_common *, hip_tlv_type_t);
 void *hip_get_param_contents_direct(const void *);
 hip_tlv_len_t hip_get_param_contents_len(const void *);
-int hip_get_param_host_id_di_type_len(struct hip_host_id *, char **, int *);
+int hip_get_param_host_id_di_type_len(struct hip_host_id *, const char **, int 
*);
 char *hip_get_param_host_id_hostname(struct hip_host_id *);
 hip_tlv_len_t hip_get_param_total_len(const void *);
 hip_transform_suite_t hip_get_param_transform_suite_id(const void *,
                                                        const uint16_t);
 hip_tlv_type_t hip_get_param_type(const void *);
 uint16_t hip_get_msg_checksum(struct hip_common *msg);
-char *hip_message_type_name(const uint8_t);
+const char *hip_message_type_name(const uint8_t);
 struct hip_common *hip_msg_alloc(void);
 void hip_msg_free(struct hip_common *);
 void hip_msg_init(struct hip_common *);
-char *hip_param_type_name(const hip_tlv_type_t);
+const char *hip_param_type_name(const hip_tlv_type_t);
 void hip_set_msg_err(struct hip_common *, hip_hdr_err_t);
 void hip_set_msg_checksum(struct hip_common *msg, uint8_t checksum);
 void hip_set_msg_total_len(struct hip_common *, uint16_t);

=== modified file 'lib/core/capability.c'
--- lib/core/capability.c       2010-05-12 16:09:38 +0000
+++ lib/core/capability.c       2010-05-17 18:24:10 +0000
@@ -39,7 +39,7 @@
  * @param the name to map
  * @return the UID or -1 on error
  */
-static int hip_user_to_uid(char *name)
+static int hip_user_to_uid(const char *name)
 {
     int uid            = -1;
     int i;

=== modified file 'lib/core/certtools.c'
--- lib/core/certtools.c        2010-04-16 01:36:19 +0000
+++ lib/core/certtools.c        2010-05-17 18:24:10 +0000
@@ -382,8 +382,8 @@
  * @return 0 if ok -1 if error
  */
 int hip_cert_spki_create_cert(struct hip_cert_spki_info *content,
-                              char *issuer_type, struct in6_addr *issuer,
-                              char *subject_type, struct in6_addr *subject,
+                              const char *issuer_type, struct in6_addr *issuer,
+                              const char *subject_type, struct in6_addr 
*subject,
                               time_t *not_before, time_t *not_after)
 {
     int err           = 0;
@@ -556,7 +556,7 @@
  * @return 0 if ok and negative if error. -1 returned for example when after 
is NOT found
  */
 int hip_cert_spki_inject(struct hip_cert_spki_info *to,
-                         char *after, char *what)
+                         const char *after, const char *what)
 {
     int err = 0, status = 0;
     regex_t re;
@@ -876,7 +876,7 @@
  *       the conf with the hip_cert_free_conf
  *
  */
-STACK_OF(CONF_VALUE) * hip_cert_read_conf_section(char *section_name,
+STACK_OF(CONF_VALUE) * hip_cert_read_conf_section(const char *section_name,
                                                   CONF * conf)
 {
     long err = 0;

=== modified file 'lib/core/certtools.h'
--- lib/core/certtools.h        2010-04-22 10:12:54 +0000
+++ lib/core/certtools.h        2010-05-17 18:24:10 +0000
@@ -59,11 +59,11 @@
 /** SPKI cert related functions */
 int hip_cert_spki_lib_verify(struct hip_cert_spki_info *);
 int hip_cert_spki_create_cert(struct hip_cert_spki_info *,
-                              char *, struct in6_addr *,
-                              char *, struct in6_addr *,
+                              const char *, struct in6_addr *,
+                              const char *, struct in6_addr *,
                               time_t *, time_t *);
 int hip_cert_spki_build_cert(struct hip_cert_spki_info *);
-int hip_cert_spki_inject(struct hip_cert_spki_info *, char *, char *);
+int hip_cert_spki_inject(struct hip_cert_spki_info *, const char *, const char 
*);
 int hip_cert_spki_construct_keys(HIP_HASHTABLE *, hip_hit_t *, RSA *);
 int hip_cert_spki_char2certinfo(char *, struct hip_cert_spki_info *);
 int hip_cert_spki_send_to_verification(struct hip_cert_spki_info *);
@@ -75,7 +75,7 @@
 /** Utilitary functions */
 X509 *hip_cert_der_to_x509(const unsigned char *, int);
 X509 *hip_cert_pem_to_x509(char *);
-STACK_OF(CONF_VALUE) * hip_cert_read_conf_section(char *, CONF *);
+STACK_OF(CONF_VALUE) * hip_cert_read_conf_section(const char *, CONF *);
 CONF *hip_cert_open_conf(void);
 void hip_cert_free_conf(CONF *);
 int hip_cert_regex(char *, char *, int *, int *);

=== modified file 'lib/core/conf.c'
--- lib/core/conf.c     2010-05-17 14:56:20 +0000
+++ lib/core/conf.c     2010-05-17 18:24:10 +0000
@@ -2235,7 +2235,7 @@
 {
     int c_count   = lib_all_length, err = 0;
     char *lib_aux = lib_all;
-    char *prefix  = HIPL_DEFAULT_PREFIX; /* translates to "/usr/local" etc */
+    const char *prefix  = HIPL_DEFAULT_PREFIX; /* translates to "/usr/local" 
etc */
 
     while (*libs != NULL) {
         /* Copying prefix to lib_all */
@@ -2315,12 +2315,12 @@
     } else if (err == 0)    {
         HIP_DEBUG("Exec new application.\n");
         if (type == EXEC_LOADLIB_HIP) {
-            libs[0] = "libhiptool.so";
+            libs[0] = strdup("libhiptool.so");
             libs[1] = NULL;
             libs[2] = NULL;
         } else if (type == EXEC_LOADLIB_OPP)   {
-            libs[0] = "libopphip.so";
-            libs[1] = "libhiptool.so";
+            libs[0] = strdup("libopphip.so");
+            libs[1] = strdup("libhiptool.so");
             libs[2] = NULL;
         }
 
@@ -2674,15 +2674,16 @@
     FILE *hip_config = NULL;
 
     List list;
-    char *c, line[128], *hip_arg, str[128], *fname, *args[64],
-    *comment, *nl;
+    char *c, line[128], *hip_arg, str[128], *args[64];
+    char *comment, *nl;
+    char fname[sizeof(HIPL_CONFIG_FILE) << 1];
 
     HIP_IFEL((optc != 1), -1, "Missing arguments\n");
 
     if (!strcmp(opt[0], "default")) {
-        fname = HIPL_CONFIG_FILE;
+        strcpy(fname, HIPL_CONFIG_FILE);
     } else {
-        fname = (char *) opt[0];
+        strcpy(fname, opt[0]);
     }
 
 

=== modified file 'lib/core/debug.c'
--- lib/core/debug.c    2010-05-17 14:56:20 +0000
+++ lib/core/debug.c    2010-05-17 18:24:10 +0000
@@ -133,12 +133,13 @@
     FILE *hip_config = NULL;
 
     List list;
-    char *c, line[128], *fname, *args[64], *comment;
+    char *c, line[128], *args[64], *comment;
+    char fname[2 * sizeof(HIPL_CONFIG_FILE)];
 
     if (!strcmp(cfile, "default")) {
-        fname = HIPL_CONFIG_FILE;
+        strcpy(fname, HIPL_CONFIG_FILE);
     } else {
-        fname = (char *) cfile;
+        strncpy(fname, cfile, sizeof(fname));
     }
 
     HIP_IFEL(!(hip_config = fopen(fname, "r")), -1,
@@ -643,7 +644,7 @@
                         const char *prefix,
                         const struct sockaddr *sockaddr)
 {
-    char *default_str = "<unknown>";
+    const char *default_str = "<unknown>";
     int maxlen;
     void *addr;
     int family        = sockaddr->sa_family;

=== modified file 'lib/core/filemanip.c'
--- lib/core/filemanip.c        2010-04-15 20:47:19 +0000
+++ lib/core/filemanip.c        2010-05-17 18:24:10 +0000
@@ -21,7 +21,7 @@
  * @param filename the file name of the lock file
  * @return zero on success and negative on error
  */
-int hip_remove_lock_file(char *filename)
+int hip_remove_lock_file(const char *filename)
 {
     return unlink(filename);
 }
@@ -34,7 +34,7 @@
  *        and existing process and kill it, or zero otherwise
  * @return zero on success and negative on error
  */
-int hip_create_lock_file(char *filename, int killold)
+int hip_create_lock_file(const char *filename, int killold)
 {
     int err     = 0, fd = 0, old_pid = 0, new_pid_str_len = 0;
     char old_pid_str[64], new_pid_str[64];
@@ -113,7 +113,7 @@
  *
  * @return 0 if successful, or negative on error.
  */
-int check_and_create_dir(char *dirname, mode_t mode)
+int check_and_create_dir(const char *dirname, mode_t mode)
 {
     int err = 0;
     struct stat dir_stat;
@@ -141,7 +141,7 @@
  *
  * @return file descriptor of the created file
  */
-int check_and_create_file(char *filename, mode_t mode)
+int check_and_create_file(const char *filename, mode_t mode)
 {
     int err = 0, fd = 0;
     struct stat file_stat;
@@ -170,7 +170,7 @@
  *
  * @param filenamebase the file name based for keys
  */
-void change_key_file_perms(char *filenamebase)
+void change_key_file_perms(const char *filenamebase)
 {
     char *pubfilename = NULL;
     int pubfilename_len;

=== modified file 'lib/core/filemanip.h'
--- lib/core/filemanip.h        2010-04-22 10:12:54 +0000
+++ lib/core/filemanip.h        2010-05-17 18:24:10 +0000
@@ -15,10 +15,10 @@
 
 #define HIP_DEFAULT_EXEC_PATH 
"/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin"
 
-int hip_create_lock_file(char *filename, int killold);
-int hip_remove_lock_file(char *filename);
-int check_and_create_dir(char *dirname, mode_t mode);
-int check_and_create_file(char *filename, mode_t mode);
-void change_key_file_perms(char *filenamebase);
+int hip_create_lock_file(const char *filename, int killold);
+int hip_remove_lock_file(const char *filename);
+int check_and_create_dir(const char *dirname, mode_t mode);
+int check_and_create_file(const char *filename, mode_t mode);
+void change_key_file_perms(const char *filenamebase);
 
 #endif /* HIP_LIB_CORE_FILEMANIP_H */

=== modified file 'lib/opphip/wrap.c'
--- lib/opphip/wrap.c   2010-05-12 16:09:38 +0000
+++ lib/opphip/wrap.c   2010-05-17 18:24:10 +0000
@@ -77,10 +77,10 @@
 /** Symbolic names for wrapper handler array. Must be filled in the same order 
as
  * @c dl_function_ptr array.
  */
-void *dl_function_name[] = { "socket",  "bind", "connect",  "send",    
"sendto",
-                             "sendmsg", "recv", "recvfrom", "recvmsg", 
"accept",
-                             "write",   "read", "close",    "listen",  "readv",
-                             "writev",  "poll"};
+const char *dl_function_name[] = { "socket",  "bind", "connect",  "send",    
"sendto",
+                                   "sendmsg", "recv", "recvfrom", "recvmsg", 
"accept",
+                                   "write",   "read", "close",    "listen",  
"readv",
+                                   "writev",  "poll"};
 
 /**
  * Initialize the @c dl_function_fd array to support wrapping of socket calls

=== modified file 'lib/tool/nlink.c'
--- lib/tool/nlink.c    2010-05-17 16:55:10 +0000
+++ lib/tool/nlink.c    2010-05-17 18:24:10 +0000
@@ -814,7 +814,7 @@
  */
 int hip_iproute_modify(struct rtnl_handle *rth,
                        int cmd, int flags, int family, char *ip,
-                       char *dev)
+                       const char *dev)
 {
     struct {
         struct nlmsghdr n;
@@ -1243,7 +1243,7 @@
  * @return zero on success and negative on failure
  */
 int hip_ipaddr_modify(struct rtnl_handle *rth, int cmd, int family, char *ip,
-                      char *dev, struct idxmap **idxmap)
+                      const char *dev, struct idxmap **idxmap)
 {
     struct {
         struct nlmsghdr  n;
@@ -1387,7 +1387,7 @@
  * @param up 1 when setting interface up and 0 for down
  * @return zero on success and negative on failure
  */
-int set_up_device(char *dev, int up)
+int set_up_device(const char *dev, int up)
 {
     int err     = -1, total_add;
     uint32_t mask  = 0;
@@ -1515,7 +1515,8 @@
  * @return zero
  */
 int xfrm_algo_parse(struct xfrm_algo *alg, enum xfrm_attr_type_t type,
-                    char *name, const unsigned char *key, int key_len, int max)
+                    const char *name, const unsigned char *key, int key_len,
+                    int max)
 {
     int len  = 0;
     int slen = key_len;

=== modified file 'lib/tool/nlink.h'
--- lib/tool/nlink.h    2010-04-21 14:18:05 +0000
+++ lib/tool/nlink.h    2010-05-17 18:24:10 +0000
@@ -67,7 +67,7 @@
 
 typedef int (*hip_filter_t)(const struct nlmsghdr *n, int len, void *arg);
 
-int set_up_device(char *dev, int up);
+int set_up_device(const char *dev, int up);
 int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data,
               int alen);
 
@@ -87,10 +87,10 @@
                  hip_filter_t junk, void *arg);
 
 int hip_ipaddr_modify(struct rtnl_handle *rth, int cmd, int family, char *ip,
-                      char *dev, struct idxmap **idxma);
+                      const char *dev, struct idxmap **idxma);
 int hip_iproute_modify(struct rtnl_handle *rth,
                        int cmd, int flags, int family, char *ip,
-                       char *dev);
+                       const char *dev);
 int hip_iproute_get(struct rtnl_handle *rth, struct in6_addr *src_addr,
                     const struct in6_addr *dst_addr, char *idev, char *odev,
                     int family, struct idxmap **idxmap);
@@ -108,7 +108,7 @@
                     const struct in6_addr *oa);
 
 int xfrm_algo_parse(struct xfrm_algo *alg, enum xfrm_attr_type_t type,
-                    char *name, const unsigned char *key,
+                    const char *name, const unsigned char *key,
                     int key_len, int max);
 
 #endif /* HIP_LIB_TOOL_NLINK_H */

=== modified file 'lib/tool/xfrmapi.c'
--- lib/tool/xfrmapi.c  2010-05-12 12:29:33 +0000
+++ lib/tool/xfrmapi.c  2010-05-17 18:24:10 +0000
@@ -40,22 +40,22 @@
 int hip_xfrmapi_beet;
 int hip_xfrmapi_sa_default_prefix;
 
-char **e_algo_names;
-char **a_algo_names;
+const char **e_algo_names;
+const char **a_algo_names;
 
 /* Mappings from HIP to XFRM algo names < 2.6.19 */
-char *e_algo_names_old[] =
+const char *e_algo_names_old[] =
 {"reserved",   "aes",         "des3_ede", "des3_ede",
  "blowfish", "cipher_null", "cipher_null"};
-char *a_algo_names_old[] =
+const char *a_algo_names_old[] =
 {"reserved", "sha1", "sha1", "md5",
  "sha1",   "sha1", "md5"};
 
 /* Mappings from HIP to XFRM algo names >= 2.6.19 */
-char *e_algo_names_new[] =
+const char *e_algo_names_new[] =
 {"reserved",        "cbc(aes)",         "cbc(des3_ede)", "cbc(des3_ede)",
  "cbc(blowfish)", "ecb(cipher_null)", "ecb(cipher_null)"};
-char *a_algo_names_new[] =
+const char *a_algo_names_new[] =
 {"reserved",     "hmac(sha1)", "hmac(sha1)", "hmac(md5)",
  "hmac(sha1)", "hmac(sha1)", "hmac(md5)"};
 
@@ -327,8 +327,8 @@
             struct xfrm_algo algo;
             char             buf[XFRM_ALGO_KEY_BUF_SIZE];
         } alg;
-        char *e_name = e_algo_names[ealg];
-        char *a_name = a_algo_names[aalg];
+        const char *e_name = e_algo_names[ealg];
+        const char *a_name = a_algo_names[aalg];
         int len;
 
         HIP_ASSERT(ealg < sizeof(e_algo_names));

Other related posts:

  • » [hipl-commit] [trunk] Rev 4546: Add the "write-strings" warning CFLAG. - Mircea Gherzan