From ecff379b6f16517e72059da869d95744dc0182d7 Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Wed, 17 Sep 2008 20:24:59 +0000 Subject: [PATCH] use sizeof var instead of constant --- amd/am_ops.c | 2 +- amd/amfs_host.c | 2 +- libamu/xutil.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/amd/am_ops.c b/amd/am_ops.c index 08e43b7..66c362c 100644 --- a/amd/am_ops.c +++ b/amd/am_ops.c @@ -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'; diff --git a/amd/amfs_host.c b/amd/amfs_host.c index cd7a757..51053da 100644 --- a/amd/amfs_host.c +++ b/amd/amfs_host.c @@ -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; diff --git a/libamu/xutil.c b/libamu/xutil.c index e99c648..b3e3a0f 100644 --- a/libamu/xutil.c +++ b/libamu/xutil.c @@ -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 */ -- 2.43.0