use sizeof var instead of constant
authorChristos Zoulas <christos@zoulas.com>
Wed, 17 Sep 2008 20:24:59 +0000 (20:24 +0000)
committerChristos Zoulas <christos@zoulas.com>
Wed, 17 Sep 2008 20:24:59 +0000 (20:24 +0000)
amd/am_ops.c
amd/amfs_host.c
libamu/xutil.c

index 08e43b7572126867c00cb8095c5d673e75dcac91..66c362c42444a4e79bfa77518b114428eb5209a5 100644 (file)
@@ -327,7 +327,7 @@ merge_opts(const char *opts1, const char *opts2)
        tmpstr;
        tmpstr = strtok(NULL, ",")) {
     /* copy option to temp buffer */
-    xstrlcpy(oneopt, tmpstr, 80);
+    xstrlcpy(oneopt, tmpstr, sizeof(oneopt));
     /* if option has a value such as rsize=1024, chop the value part */
     if ((eq = haseq(oneopt)))
       *eq = '\0';
index cd7a7578cb4190dad06fb4a0533f494cf91bace9..51053dac15a26b6705b246dda8e64f758bf5a2ec 100644 (file)
@@ -465,7 +465,7 @@ amfs_host_mount(am_node *am, mntfs *mf)
    * error code 0 at the end.  If they all fail then return
    * the last error code.
    */
-  xstrlcpy(fs_name, mf->mf_info, MAXPATHLEN);
+  xstrlcpy(fs_name, mf->mf_info, sizeof(fs_name));
   if ((rfs_dir = strchr(fs_name, ':')) == (char *) NULL) {
     plog(XLOG_FATAL, "amfs_host_mount: mf_info has no colon");
     error = EINVAL;
index e99c6488a888affcfd599b1636815c5cdfd52f13..b3e3a0ffc9713a2e2094d01e32effea864131268 100644 (file)
@@ -150,7 +150,7 @@ am_get_progname(void)
 void
 am_set_hostname(char *hn)
 {
-  xstrlcpy(am_hostname, hn, MAXHOSTNAMELEN);
+  xstrlcpy(am_hostname, hn, sizeof(am_hostname));
 }
 
 
@@ -520,7 +520,7 @@ real_plog(int lvl, const char *fmt, va_list vargs)
   switch (last_count) {
   case 0:                      /* never printed at all */
     last_count = 1;
-    if (strlcpy(last_msg, msg, 1024) >= 1024) /* don't use xstrlcpy here (recursive!) */
+    if (strlcpy(last_msg, msg, sizeof(last_msg)) >= sizeof(last_msg)) /* don't use xstrlcpy here (recursive!) */
       fprintf(stderr, "real_plog: string \"%s\" truncated to \"%s\"\n", last_msg, msg);
     last_lvl = lvl;
     show_time_host_and_name(lvl); /* mimic syslog header */
@@ -533,7 +533,7 @@ real_plog(int lvl, const char *fmt, va_list vargs)
       last_count++;
     } else {                   /* last msg printed once, new one differs */
       /* last_count remains at 1 */
-      if (strlcpy(last_msg, msg, 1024) >= 1024) /* don't use xstrlcpy here (recursive!) */
+      if (strlcpy(last_msg, msg, sizeof(last_msg)) >= sizeof(last_msg)) /* don't use xstrlcpy here (recursive!) */
        fprintf(stderr, "real_plog: string \"%s\" truncated to \"%s\"\n", last_msg, msg);
       last_lvl = lvl;
       show_time_host_and_name(lvl); /* mimic syslog header */