summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--utils/mirror_vfd/mirror_remote.c11
-rw-r--r--utils/mirror_vfd/mirror_remote.h5
-rw-r--r--utils/mirror_vfd/mirror_server.c37
-rw-r--r--utils/mirror_vfd/mirror_server_stop.c2
-rw-r--r--utils/mirror_vfd/mirror_writer.c51
5 files changed, 24 insertions, 82 deletions
diff --git a/utils/mirror_vfd/mirror_remote.c b/utils/mirror_vfd/mirror_remote.c
index 170d61d..d5f2e89 100644
--- a/utils/mirror_vfd/mirror_remote.c
+++ b/utils/mirror_vfd/mirror_remote.c
@@ -10,9 +10,8 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/* Common operations for "remote" processes for the Mirror VFD.
- *
- * Jacob Smith, 2020-03-06
+/*
+ * Common operations for "remote" processes for the mirror VFD
*/
#include "mirror_remote.h"
@@ -31,19 +30,19 @@ mirror_log(struct mirror_log_info *info, unsigned int level, const char *format,
{
FILE *stream = MIRROR_LOG_DEFAULT_STREAM;
unsigned int verbosity = MIRROR_LOG_DEFAULT_VERBOSITY;
- hbool_t custom = FALSE;
+ bool custom = false;
if (info != NULL && info->magic == MIRROR_LOG_INFO_MAGIC) {
stream = info->stream;
verbosity = info->verbosity;
- custom = TRUE;
+ custom = true;
}
if (level == V_NONE) {
return;
}
else if (level <= verbosity) {
- if (custom == TRUE && info->prefix[0] != '\0') {
+ if (custom == true && info->prefix[0] != '\0') {
HDfprintf(stream, "%s", info->prefix);
}
diff --git a/utils/mirror_vfd/mirror_remote.h b/utils/mirror_vfd/mirror_remote.h
index 02cf41b..00a09b0 100644
--- a/utils/mirror_vfd/mirror_remote.h
+++ b/utils/mirror_vfd/mirror_remote.h
@@ -10,9 +10,8 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-/* Common definitions for "remote" processes for the Mirror VFD.
- *
- * Jacob Smith, 2020-03-06
+/*
+ * Common definitions for "remote" processes for the mirror VFD
*/
#include "hdf5.h"
diff --git a/utils/mirror_vfd/mirror_server.c b/utils/mirror_vfd/mirror_server.c
index 79c9d80..25ab36d 100644
--- a/utils/mirror_vfd/mirror_server.c
+++ b/utils/mirror_vfd/mirror_server.c
@@ -131,27 +131,6 @@ struct server_run {
};
/* ---------------------------------------------------------------------------
- * Function: mybzero
- *
- * Purpose: Introduce bzero without neededing it on the system.
- *
- * Programmer: Jacob Smith
- * 2020-03-30
- * ---------------------------------------------------------------------------
- */
-static void
-mybzero(void *dest, size_t size)
-{
- size_t i = 0;
- char *s = NULL;
- HDassert(dest);
- s = (char *)dest;
- for (i = 0; i < size; i++) {
- *(s + i) = 0;
- }
-} /* end mybzero() */
-
-/* ---------------------------------------------------------------------------
* Function: usage
*
* Purpose: Print the usage message to stdout.
@@ -190,18 +169,16 @@ usage(void)
static int
parse_args(int argc, char **argv, struct op_args *args_out)
{
- int i;
-
- /* preset default values
- */
+ /* Preset default values */
args_out->main_port = DEFAULT_PORT;
args_out->help = 0;
args_out->log_prepend_serv = 1;
args_out->log_prepend_type = 1;
args_out->verbosity = MIRROR_LOG_DEFAULT_VERBOSITY;
- /* preset empty strings */
- mybzero(args_out->log_path, PATH_MAX + 1);
- mybzero(args_out->writer_log_path, PATH_MAX + 1);
+
+ /* Preset empty strings */
+ HDmemset(args_out->log_path, 0, PATH_MAX + 1);
+ HDmemset(args_out->writer_log_path, 0, PATH_MAX + 1);
if (argv == NULL || *argv == NULL) {
mirror_log(NULL, V_ERR, "invalid argv pointer");
@@ -209,7 +186,7 @@ parse_args(int argc, char **argv, struct op_args *args_out)
}
/* Loop over arguments after program name */
- for (i = 1; i < argc; i++) {
+ for (int i = 1; i < argc; i++) {
if (!HDstrncmp(argv[i], "-h", 3) || !HDstrncmp(argv[i], "--help", 7)) {
mirror_log(NULL, V_INFO, "found help argument");
args_out->help = 1;
@@ -569,7 +546,7 @@ handle_requests(struct server_run *run)
mirror_log(run->loginfo, V_INFO, "probable OPEN xmit received");
H5FD_mirror_xmit_decode_open(xopen, (const unsigned char *)mybuf);
- if (FALSE == H5FD_mirror_xmit_is_open(xopen)) {
+ if (false == H5FD_mirror_xmit_is_open(xopen)) {
mirror_log(run->loginfo, V_WARN, "expected OPEN xmit was malformed");
HDclose(connfd);
continue;
diff --git a/utils/mirror_vfd/mirror_server_stop.c b/utils/mirror_vfd/mirror_server_stop.c
index 44386bf..c2874b7 100644
--- a/utils/mirror_vfd/mirror_server_stop.c
+++ b/utils/mirror_vfd/mirror_server_stop.c
@@ -146,7 +146,7 @@ send_shutdown(struct mshs_opts *opts)
target_addr.sin_family = AF_INET;
target_addr.sin_port = HDhtons((uint16_t)opts->portno);
target_addr.sin_addr.s_addr = HDinet_addr(opts->ip);
- HDmemset(target_addr.sin_zero, '\0', sizeof(target_addr.sin_zero));
+ HDmemset(target_addr.sin_zero, 0, sizeof(target_addr.sin_zero));
if (HDconnect(live_socket, (struct sockaddr *)&target_addr, (socklen_t)sizeof(target_addr)) < 0) {
HDprintf("ERROR connect() (%d)\n%s\n", errno, HDstrerror(errno));
diff --git a/utils/mirror_vfd/mirror_writer.c b/utils/mirror_vfd/mirror_writer.c
index ad7cd91..2752121 100644
--- a/utils/mirror_vfd/mirror_writer.c
+++ b/utils/mirror_vfd/mirror_writer.c
@@ -154,32 +154,9 @@ struct mirror_writer_opts {
char *logpath;
};
-static void mybzero(void *dest, size_t size);
-
static int do_open(struct mirror_session *session, const H5FD_mirror_xmit_open_t *xmit_open);
/* ---------------------------------------------------------------------------
- * Function: mybzero
- *
- * Purpose: Introduce bzero without neededing it on the system.
- *
- * Programmer: Jacob Smith
- * 2020-03-30
- * ---------------------------------------------------------------------------
- */
-static void
-mybzero(void *dest, size_t size)
-{
- size_t i = 0;
- char *s = NULL;
- HDassert(dest);
- s = (char *)dest;
- for (i = 0; i < size; i++) {
- *(s + i) = 0;
- }
-} /* end mybzero() */
-
-/* ---------------------------------------------------------------------------
* Function: session_init
*
* Purpose: Populate mirror_session structure with default and
@@ -217,10 +194,9 @@ session_init(struct mirror_writer_opts *opts)
session->reply.pub.version = H5FD_MIRROR_XMIT_CURR_VERSION;
session->reply.pub.op = H5FD_MIRROR_OP_REPLY;
session->reply.pub.session_token = 0;
- mybzero(session->reply.message, H5FD_MIRROR_STATUS_MESSAGE_MAX);
+ HDmemset(session->reply.message, 0, H5FD_MIRROR_STATUS_MESSAGE_MAX);
- /* Options-derived population
- */
+ /* Options-derived population */
session->loginfo = mirror_log_init(opts->logpath, "W- ", MIRROR_LOG_DEFAULT_VERBOSITY);
@@ -291,25 +267,16 @@ session_start(int socketfd, const H5FD_mirror_xmit_open_t *xmit_open)
{
struct mirror_session *session = NULL;
struct mirror_writer_opts opts;
-#if 0 /* TODO: behavior option */
- char logpath[H5FD_MIRROR_XMIT_FILEPATH_MAX] = "";
-#endif
mirror_log(NULL, V_INFO, "session_start()");
- if (FALSE == H5FD_mirror_xmit_is_open(xmit_open)) {
+ if (false == H5FD_mirror_xmit_is_open(xmit_open)) {
mirror_log(NULL, V_ERR, "invalid OPEN xmit");
return NULL;
}
- opts.magic = MW_OPTS_MAGIC;
-#if 0 /* TODO: behavior option */
- HDsnprintf(logpath, H5FD_MIRROR_XMIT_FILEPATH_MAX, "%s.log",
- xmit_open->filename);
- opts.logpath = logpath;
-#else
+ opts.magic = MW_OPTS_MAGIC;
opts.logpath = NULL;
-#endif
session = session_init(&opts);
if (NULL == session) {
@@ -391,7 +358,7 @@ reply_ok(struct mirror_session *session)
mirror_log(session->loginfo, V_ALL, "reply_ok()");
reply->status = H5FD_MIRROR_STATUS_OK;
- mybzero(reply->message, H5FD_MIRROR_STATUS_MESSAGE_MAX);
+ HDmemset(reply->message, 0, H5FD_MIRROR_STATUS_MESSAGE_MAX);
return _xmit_reply(session);
} /* end reply_ok() */
@@ -489,7 +456,7 @@ do_lock(struct mirror_session *session, const unsigned char *xmit_buf)
}
mirror_log(session->loginfo, V_INFO, "lock rw: (%d)", xmit_lock.rw);
- if (H5FDlock(session->file, (hbool_t)xmit_lock.rw) < 0) {
+ if (H5FDlock(session->file, (bool)xmit_lock.rw) < 0) {
mirror_log(session->loginfo, V_ERR, "H5FDlock()");
reply_error(session, "remote H5FDlock() failure");
return -1;
@@ -520,7 +487,7 @@ do_open(struct mirror_session *session, const H5FD_mirror_xmit_open_t *xmit_open
haddr_t _maxaddr = HADDR_UNDEF;
HDassert(session && (session->magic == MW_SESSION_MAGIC) && xmit_open &&
- TRUE == H5FD_mirror_xmit_is_open(xmit_open));
+ true == H5FD_mirror_xmit_is_open(xmit_open));
mirror_log(session->loginfo, V_INFO, "do_open()");
@@ -664,7 +631,7 @@ do_truncate(struct mirror_session *session)
mirror_log(session->loginfo, V_INFO, "do_truncate()");
- /* default DXPL ID (0), 0 for "FALSE" closing -- both probably unused */
+ /* default DXPL ID (0), 0 for "false" closing -- both probably unused */
if (H5FDtruncate(session->file, 0, 0) < 0) {
mirror_log(session->loginfo, V_ERR, "H5FDtruncate()");
reply_error(session, "remote H5FDtruncate() failure");
@@ -853,7 +820,7 @@ receive_communique(struct mirror_session *session, struct sock_comm *comm)
mirror_log(session->loginfo, V_INFO, "receive_communique()");
- mybzero(comm->raw, comm->raw_size);
+ HDmemset(comm->raw, 0, comm->raw_size);
comm->recd_die = 0;
mirror_log(session->loginfo, V_INFO, "ready to receive"); /* TODO */