Repository: trafficserver Updated Branches: refs/heads/master 1cfc9aeec -> 126f420a0
TS-1256: use a consistent definition of PATH_NAME_MAX Since we define what PATH_NAME_MAX is ourselves, we should streamline our code to only use PATH_NAME_MAX, not PATH_NAME_MAX + 1. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/126f420a Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/126f420a Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/126f420a Branch: refs/heads/master Commit: 126f420a0eab97b7cfc850231f1bafc52c2eaf98 Parents: 1cfc9ae Author: Byungwook Ahn <[email protected]> Authored: Mon Mar 23 21:30:06 2015 -0700 Committer: James Peach <[email protected]> Committed: Mon Mar 23 21:31:24 2015 -0700 ---------------------------------------------------------------------- cmd/traffic_cop/traffic_cop.cc | 10 +++++----- cmd/traffic_manager/traffic_manager.cc | 2 +- iocore/cache/Store.cc | 12 ++++++------ iocore/hostdb/HostDB.cc | 14 +++++++------- iocore/hostdb/MultiCache.cc | 6 +++--- iocore/hostdb/P_HostDBProcessor.h | 2 +- iocore/hostdb/P_MultiCache.h | 2 +- lib/records/RecCore.cc | 12 ++++++------ proxy/InkAPI.cc | 2 +- proxy/InkAPITest.cc | 2 +- proxy/Plugin.cc | 2 +- proxy/StatSystem.cc | 4 ++-- proxy/shared/DiagsConfig.cc | 2 +- 13 files changed, 36 insertions(+), 36 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/126f420a/cmd/traffic_cop/traffic_cop.cc ---------------------------------------------------------------------- diff --git a/cmd/traffic_cop/traffic_cop.cc b/cmd/traffic_cop/traffic_cop.cc index 115b1cc..15a1cef 100644 --- a/cmd/traffic_cop/traffic_cop.cc +++ b/cmd/traffic_cop/traffic_cop.cc @@ -542,7 +542,7 @@ ConfigIntFatalError: static char * config_read_runtime_dir() { - char state_dir[PATH_NAME_MAX + 1]; + char state_dir[PATH_NAME_MAX]; state_dir[0] = '\0'; config_read_string("proxy.config.local_state_dir", state_dir, sizeof(state_dir), true); @@ -556,7 +556,7 @@ config_read_runtime_dir() static char * config_read_sysconfig_dir() { - char sysconfig_dir[PATH_NAME_MAX + 1]; + char sysconfig_dir[PATH_NAME_MAX]; sysconfig_dir[0] = '\0'; config_read_string("proxy.config.config_dir", sysconfig_dir, sizeof(sysconfig_dir), true); @@ -570,7 +570,7 @@ config_read_sysconfig_dir() static char * config_read_bin_dir() { - char bindir[PATH_NAME_MAX + 1]; + char bindir[PATH_NAME_MAX]; bindir[0] = '\0'; config_read_string("proxy.config.bin_path", bindir, sizeof(bindir), true); @@ -585,7 +585,7 @@ config_read_bin_dir() static char * config_read_log_dir() { - char logdir[PATH_NAME_MAX + 1]; + char logdir[PATH_NAME_MAX]; logdir[0] = '\0'; config_read_string("proxy.config.log.logfile_dir", logdir, sizeof(logdir), true); @@ -1572,7 +1572,7 @@ check_memory() static int check_no_run() { - char path[PATH_NAME_MAX * 2]; + char path[PATH_NAME_MAX]; struct stat info; int err; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/126f420a/cmd/traffic_manager/traffic_manager.cc ---------------------------------------------------------------------- diff --git a/cmd/traffic_manager/traffic_manager.cc b/cmd/traffic_manager/traffic_manager.cc index 5133c18..a03c4ee 100644 --- a/cmd/traffic_manager/traffic_manager.cc +++ b/cmd/traffic_manager/traffic_manager.cc @@ -76,7 +76,7 @@ static char debug_tags[1024] = ""; static char action_tags[1024] = ""; static bool proxy_on = true; -static char mgmt_path[PATH_NAME_MAX + 1]; +static char mgmt_path[PATH_NAME_MAX]; // By default, set the current directory as base static const char *recs_conf = "records.config"; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/126f420a/iocore/cache/Store.cc ---------------------------------------------------------------------- diff --git a/iocore/cache/Store.cc b/iocore/cache/Store.cc index 2fac7b4..84af046 100644 --- a/iocore/cache/Store.cc +++ b/iocore/cache/Store.cc @@ -275,7 +275,7 @@ Span::~Span() static int get_int64(int fd, int64_t &data) { - char buf[PATH_NAME_MAX + 1]; + char buf[PATH_NAME_MAX]; if (ink_file_fd_readline(fd, PATH_NAME_MAX, buf) <= 0) return (-1); // the above line will guarantee buf to be no longer than PATH_NAME_MAX @@ -438,7 +438,7 @@ Lfail: const char * Store::read_interim_config() { - char p[PATH_NAME_MAX + 1]; + char p[PATH_NAME_MAX]; Span *sd = NULL; Span *ns; int interim_store = 0; @@ -842,7 +842,7 @@ Store::write(int fd, const char *name) const int Span::read(int fd) { - char buf[PATH_NAME_MAX + 1], p[PATH_NAME_MAX + 1]; + char buf[PATH_NAME_MAX], p[PATH_NAME_MAX]; if (ink_file_fd_readline(fd, PATH_NAME_MAX, buf) <= 0) return (-1); @@ -888,8 +888,8 @@ int Store::read(int fd, char *aname) { char *name = aname; - char tname[PATH_NAME_MAX + 1]; - char buf[PATH_NAME_MAX + 1]; + char tname[PATH_NAME_MAX]; + char buf[PATH_NAME_MAX]; if (!aname) name = tname; @@ -973,7 +973,7 @@ Store::clear(char *filename, bool clear_dirs) for (unsigned i = 0; i < n_disks; i++) { Span *ds = disk[i]; for (unsigned j = 0; j < disk[i]->paths(); j++) { - char path[PATH_NAME_MAX + 1]; + char path[PATH_NAME_MAX]; Span *d = ds->nth(j); if (!clear_dirs && !d->file_pathname) continue; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/126f420a/iocore/hostdb/HostDB.cc ---------------------------------------------------------------------- diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc index 9add8a9..a7f5c55 100644 --- a/iocore/hostdb/HostDB.cc +++ b/iocore/hostdb/HostDB.cc @@ -58,9 +58,9 @@ unsigned int hostdb_serve_stale_but_revalidate = 0; unsigned int hostdb_hostfile_check_interval = 86400; // 1 day unsigned int hostdb_hostfile_update_timestamp = 0; unsigned int hostdb_hostfile_check_timestamp = 0; -char hostdb_filename[PATH_NAME_MAX + 1] = DEFAULT_HOST_DB_FILENAME; +char hostdb_filename[PATH_NAME_MAX] = DEFAULT_HOST_DB_FILENAME; int hostdb_size = DEFAULT_HOST_DB_SIZE; -char hostdb_hostfile_path[PATH_NAME_MAX + 1] = ""; +char hostdb_hostfile_path[PATH_NAME_MAX] = ""; int hostdb_sync_frequency = 120; int hostdb_srv_enabled = 0; int hostdb_disable_reverse_lookup = 0; @@ -413,7 +413,7 @@ HostDBCache::start(int flags) { Store *hostDBStore; Span *hostDBSpan; - char storage_path[PATH_NAME_MAX + 1]; + char storage_path[PATH_NAME_MAX]; int storage_size = 33554432; // 32MB default bool reconfigure = ((flags & PROCESSOR_RECONFIGURE) ? true : false); @@ -425,10 +425,10 @@ HostDBCache::start(int flags) // Command line overrides manager configuration. // REC_ReadConfigInt32(hostdb_enable, "proxy.config.hostdb"); - REC_ReadConfigString(hostdb_filename, "proxy.config.hostdb.filename", PATH_NAME_MAX); + REC_ReadConfigString(hostdb_filename, "proxy.config.hostdb.filename", sizeof(hostdb_filename)); REC_ReadConfigInt32(hostdb_size, "proxy.config.hostdb.size"); REC_ReadConfigInt32(hostdb_srv_enabled, "proxy.config.srv_enabled"); - REC_ReadConfigString(storage_path, "proxy.config.hostdb.storage_path", PATH_NAME_MAX); + REC_ReadConfigString(storage_path, "proxy.config.hostdb.storage_path", sizeof(storage_path)); REC_ReadConfigInt32(storage_size, "proxy.config.hostdb.storage_size"); // If proxy.config.hostdb.storage_path is not set, use the local state dir. If it is set to @@ -2124,9 +2124,9 @@ HostDBContinuation::backgroundEvent(int /* event ATS_UNUSED */, Event * /* e ATS struct stat info; char path[sizeof(hostdb_hostfile_path)]; - REC_ReadConfigString(path, "proxy.config.hostdb.host_file.path", PATH_NAME_MAX); + REC_ReadConfigString(path, "proxy.config.hostdb.host_file.path", sizeof(path)); if (0 != strcasecmp(hostdb_hostfile_path, path)) { - Debug("amc", "Update host file '%s' <- '%s'", path, hostdb_hostfile_path); + Debug("hostdb", "Update host file '%s' <- '%s'", path, hostdb_hostfile_path); // path to hostfile changed hostdb_hostfile_update_timestamp = 0; // never updated from this file memcpy(hostdb_hostfile_path, path, sizeof(hostdb_hostfile_path)); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/126f420a/iocore/hostdb/MultiCache.cc ---------------------------------------------------------------------- diff --git a/iocore/hostdb/MultiCache.cc b/iocore/hostdb/MultiCache.cc index b219631..2b37be1 100644 --- a/iocore/hostdb/MultiCache.cc +++ b/iocore/hostdb/MultiCache.cc @@ -309,7 +309,7 @@ MultiCacheBase::mmap_data(bool private_flag, bool zero_fill) for (unsigned i = 0; i < store->n_disks; i++) { Span *ds = store->disk[i]; for (unsigned j = 0; j < store->disk[i]->paths(); j++) { - char path[PATH_NAME_MAX + 1]; + char path[PATH_NAME_MAX]; Span *d = ds->nth(j); int r = d->path(filename, NULL, path, PATH_NAME_MAX); if (r < 0) { @@ -503,7 +503,7 @@ MultiCacheBase::read_config(const char *config_filename, Store &s, char *fn, int { int scratch; ats_scoped_str rundir(RecConfigReadRuntimeDir()); - char p[PATH_NAME_MAX + 1], buf[256]; + char p[PATH_NAME_MAX], buf[256]; Layout::relative_to(p, sizeof(p), rundir, config_filename); @@ -539,7 +539,7 @@ int MultiCacheBase::write_config(const char *config_filename, int nominal_size, int abuckets) { ats_scoped_str rundir(RecConfigReadRuntimeDir()); - char p[PATH_NAME_MAX + 1], buf[256]; + char p[PATH_NAME_MAX], buf[256]; int fd, retcode = -1; Layout::relative_to(p, sizeof(p), rundir, config_filename); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/126f420a/iocore/hostdb/P_HostDBProcessor.h ---------------------------------------------------------------------- diff --git a/iocore/hostdb/P_HostDBProcessor.h b/iocore/hostdb/P_HostDBProcessor.h index 5f2b908..d80bc6e 100644 --- a/iocore/hostdb/P_HostDBProcessor.h +++ b/iocore/hostdb/P_HostDBProcessor.h @@ -57,7 +57,7 @@ extern unsigned int hostdb_ip_timeout_interval; extern unsigned int hostdb_ip_fail_timeout_interval; extern int hostdb_size; extern int hostdb_srv_enabled; -extern char hostdb_filename[PATH_NAME_MAX + 1]; +extern char hostdb_filename[PATH_NAME_MAX]; // extern int hostdb_timestamp; extern int hostdb_sync_frequency; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/126f420a/iocore/hostdb/P_MultiCache.h ---------------------------------------------------------------------- diff --git a/iocore/hostdb/P_MultiCache.h b/iocore/hostdb/P_MultiCache.h index 8f9478c..01a9f02 100644 --- a/iocore/hostdb/P_MultiCache.h +++ b/iocore/hostdb/P_MultiCache.h @@ -191,7 +191,7 @@ struct MultiCacheHeapGC; struct MultiCacheBase : public MultiCacheHeader { Store *store; - char filename[PATH_NAME_MAX + 1]; + char filename[PATH_NAME_MAX]; MultiCacheHeader *mapped_header; MultiCacheHeader header_snap; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/126f420a/lib/records/RecCore.cc ---------------------------------------------------------------------- diff --git a/lib/records/RecCore.cc b/lib/records/RecCore.cc index b326e14..b4ccd81 100644 --- a/lib/records/RecCore.cc +++ b/lib/records/RecCore.cc @@ -1101,7 +1101,7 @@ REC_readString(const char *name, bool *found, bool lock) char * RecConfigReadConfigDir() { - char buf[PATH_NAME_MAX + 1]; + char buf[PATH_NAME_MAX]; buf[0] = '\0'; RecGetRecordString("proxy.config.config_dir", buf, PATH_NAME_MAX); @@ -1118,7 +1118,7 @@ RecConfigReadConfigDir() char * RecConfigReadRuntimeDir() { - char buf[PATH_NAME_MAX + 1]; + char buf[PATH_NAME_MAX]; buf[0] = '\0'; RecGetRecordString("proxy.config.local_state_dir", buf, PATH_NAME_MAX); @@ -1135,7 +1135,7 @@ RecConfigReadRuntimeDir() char * RecConfigReadLogDir() { - char buf[PATH_NAME_MAX + 1]; + char buf[PATH_NAME_MAX]; buf[0] = '\0'; RecGetRecordString("proxy.config.log.logfile_dir", buf, PATH_NAME_MAX); @@ -1152,7 +1152,7 @@ RecConfigReadLogDir() char * RecConfigReadBinDir() { - char buf[PATH_NAME_MAX + 1]; + char buf[PATH_NAME_MAX]; buf[0] = '\0'; RecGetRecordString("proxy.config.bin_path", buf, PATH_NAME_MAX); @@ -1182,7 +1182,7 @@ RecConfigReadConfigPath(const char *file_variable, const char *default_value) // If the file name is in a configuration variable, look it up first ... if (file_variable) { - char buf[PATH_NAME_MAX + 1]; + char buf[PATH_NAME_MAX]; buf[0] = '\0'; RecGetRecordString(file_variable, buf, PATH_NAME_MAX); @@ -1205,7 +1205,7 @@ RecConfigReadConfigPath(const char *file_variable, const char *default_value) char * RecConfigReadPrefixPath(const char *file_variable, const char *default_value) { - char buf[PATH_NAME_MAX + 1]; + char buf[PATH_NAME_MAX]; // If the file name is in a configuration variable, look it up first ... if (file_variable) { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/126f420a/proxy/InkAPI.cc ---------------------------------------------------------------------- diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc index d85dd4e..6c73d16 100644 --- a/proxy/InkAPI.cc +++ b/proxy/InkAPI.cc @@ -1759,7 +1759,7 @@ TSTrafficServerVersionGetPatch() const char * TSPluginDirGet(void) { - static char path[PATH_NAME_MAX + 1] = ""; + static char path[PATH_NAME_MAX] = ""; if (*path == '\0') { char *plugin_dir = RecConfigReadPrefixPath("proxy.config.plugin.plugin_dir"); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/126f420a/proxy/InkAPITest.cc ---------------------------------------------------------------------- diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc index 8665aca..de5e319 100644 --- a/proxy/InkAPITest.cc +++ b/proxy/InkAPITest.cc @@ -891,7 +891,7 @@ REGRESSION_TEST(SDK_API_TSfopen)(RegressionTest *test, int /* atype ATS_UNUSED * { *pstatus = REGRESSION_TEST_INPROGRESS; - char write_file_name[PATH_NAME_MAX + 1]; + char write_file_name[PATH_NAME_MAX]; TSFile source_read_file; // existing file TSFile write_file; // to be created http://git-wip-us.apache.org/repos/asf/trafficserver/blob/126f420a/proxy/Plugin.cc ---------------------------------------------------------------------- diff --git a/proxy/Plugin.cc b/proxy/Plugin.cc index da36c1a..85db1ea 100644 --- a/proxy/Plugin.cc +++ b/proxy/Plugin.cc @@ -73,7 +73,7 @@ PluginRegInfo::~PluginRegInfo() static bool plugin_load(int argc, char *argv[], bool validateOnly) { - char path[PATH_NAME_MAX + 1]; + char path[PATH_NAME_MAX]; init_func_t init; if (argc < 1) { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/126f420a/proxy/StatSystem.cc ---------------------------------------------------------------------- diff --git a/proxy/StatSystem.cc b/proxy/StatSystem.cc index 0c64425..4a4b7a0 100644 --- a/proxy/StatSystem.cc +++ b/proxy/StatSystem.cc @@ -66,7 +66,7 @@ ink_hrtime http_handler_times[MAX_HTTP_HANDLER_EVENTS]; int http_handler_counts[MAX_HTTP_HANDLER_EVENTS]; -char snap_filename[PATH_NAME_MAX + 1] = DEFAULT_SNAP_FILENAME; +char snap_filename[PATH_NAME_MAX] = DEFAULT_SNAP_FILENAME; #define DEFAULT_PERSISTENT @@ -420,7 +420,7 @@ void initialize_all_global_stats() { int istat, i; - char snap_file[PATH_NAME_MAX + 1]; + char snap_file[PATH_NAME_MAX]; ats_scoped_str rundir(RecConfigReadRuntimeDir()); if (access(rundir, R_OK | W_OK) == -1) { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/126f420a/proxy/shared/DiagsConfig.cc ---------------------------------------------------------------------- diff --git a/proxy/shared/DiagsConfig.cc b/proxy/shared/DiagsConfig.cc index 2a8d158..91f1f9a 100644 --- a/proxy/shared/DiagsConfig.cc +++ b/proxy/shared/DiagsConfig.cc @@ -266,7 +266,7 @@ DiagsConfig::RegisterDiagConfig() DiagsConfig::DiagsConfig(const char *filename, const char *tags, const char *actions, bool use_records) { - char diags_logpath[PATH_NAME_MAX + 1]; + char diags_logpath[PATH_NAME_MAX]; ats_scoped_str logpath; callbacks_established = false;
