diff options
author | Larry Knox <lrknox@hdfgroup.org> | 2022-02-21 21:32:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-21 21:32:29 (GMT) |
commit | 3107fafa2ce858b598617463334d3d6d01dc1e4c (patch) | |
tree | 68e4cafcbbd96fa35dfd4a66a55078509e928c7b | |
parent | c302773438a4db0b56d32eaf9cf8a92b56848c0a (diff) | |
download | hdf5-3107fafa2ce858b598617463334d3d6d01dc1e4c.zip hdf5-3107fafa2ce858b598617463334d3d6d01dc1e4c.tar.gz hdf5-3107fafa2ce858b598617463334d3d6d01dc1e4c.tar.bz2 |
Oess 168 utils mirror vfd (#1444)
* Committing clang-format changes
* Spelling of preceed was corrected to proceed, but should have been
corrected to precede.
* Correct spelling correction of 'preceed' incorrectly to 'proceed'. It should be 'precede'.
* OESS-168: Remove clang warnings.
* OESS-168: Address @lrknox and @gnuoyd reviews.
* Eliminate clang warnings listed in PR #1310 without adding new ssize_t
variables.
* Committing clang-format changes
* Add H5_ATTR_UNUSED to wait_for_child call.
Remove unneeded casts in mirror_log calls.
* Keep ssize_t in mirror_server.c line 479.
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Hyo-Kyung Lee <hyoklee@hdfgroup.org>
-rw-r--r-- | src/H5FDmirror_priv.h | 4 | ||||
-rw-r--r-- | utils/mirror_vfd/mirror_remote.c | 2 | ||||
-rw-r--r-- | utils/mirror_vfd/mirror_remote.h | 2 | ||||
-rw-r--r-- | utils/mirror_vfd/mirror_server.c | 27 | ||||
-rw-r--r-- | utils/mirror_vfd/mirror_writer.c | 8 |
5 files changed, 20 insertions, 23 deletions
diff --git a/src/H5FDmirror_priv.h b/src/H5FDmirror_priv.h index 6a7b13e..f647c21 100644 --- a/src/H5FDmirror_priv.h +++ b/src/H5FDmirror_priv.h @@ -28,10 +28,10 @@ extern "C" { * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ -/* The maximum allowed size for a receiving buffer when accepting bytes to +/* Define the maximum allowed size for a receiving buffer when accepting bytes to * write. Writes larger than this size are performed by multiple accept-write * steps by the Writer. */ -#define H5FD_MIRROR_DATA_BUFFER_MAX H5_GB /* 1 Gigabyte */ +#define H5FD_MIRROR_DATA_BUFFER_MAX (1024 * 1024 * 1024) /* 1 Gigabyte */ #define H5FD_MIRROR_XMIT_CURR_VERSION 1 #define H5FD_MIRROR_XMIT_MAGIC 0x87F8005B diff --git a/utils/mirror_vfd/mirror_remote.c b/utils/mirror_vfd/mirror_remote.c index f61580d..8bb9544 100644 --- a/utils/mirror_vfd/mirror_remote.c +++ b/utils/mirror_vfd/mirror_remote.c @@ -147,7 +147,7 @@ mirror_log_bytes(struct mirror_log_info *info, unsigned int level, size_t n_byte * ---------------------------------------------------------------------------- */ loginfo_t * -mirror_log_init(char *path, char *prefix, unsigned int verbosity) +mirror_log_init(char *path, const char *prefix, unsigned int verbosity) { loginfo_t *info = NULL; diff --git a/utils/mirror_vfd/mirror_remote.h b/utils/mirror_vfd/mirror_remote.h index 6f37b0b..9415f7f 100644 --- a/utils/mirror_vfd/mirror_remote.h +++ b/utils/mirror_vfd/mirror_remote.h @@ -42,7 +42,7 @@ typedef struct mirror_log_info { void mirror_log(loginfo_t *info, unsigned int level, const char *format, ...); void mirror_log_bytes(loginfo_t *info, unsigned int level, size_t n_bytes, const unsigned char *buf); -loginfo_t *mirror_log_init(char *path, char *prefix, unsigned int verbosity); +loginfo_t *mirror_log_init(char *path, const char *prefix, unsigned int verbosity); int mirror_log_term(loginfo_t *loginfo); herr_t run_writer(int socketfd, H5FD_mirror_xmit_open_t *xmit_open); diff --git a/utils/mirror_vfd/mirror_server.c b/utils/mirror_vfd/mirror_server.c index f6a8bfe..5381d95 100644 --- a/utils/mirror_vfd/mirror_server.c +++ b/utils/mirror_vfd/mirror_server.c @@ -94,14 +94,14 @@ * --------------------------------------------------------------------------- */ struct op_args { - uint32_t magic; - int help; - int main_port; - int verbosity; - int log_prepend_serv; - int log_prepend_type; - char log_path[PATH_MAX + 1]; - char writer_log_path[PATH_MAX + 1]; + uint32_t magic; + int help; + int main_port; + unsigned int verbosity; + int log_prepend_serv; + int log_prepend_type; + char log_path[PATH_MAX + 1]; + char writer_log_path[PATH_MAX + 1]; }; /* --------------------------------------------------------------------------- @@ -224,7 +224,7 @@ parse_args(int argc, char **argv, struct op_args *args_out) } /* end if port */ else if (!HDstrncmp(argv[i], "--verbosity=", 12)) { mirror_log(NULL, V_INFO, "parsing 'verbosity' (%s)", argv[i] + 12); - args_out->verbosity = HDatoi(argv[i] + 12); + args_out->verbosity = (unsigned int)HDatoi(argv[i] + 12); } /* end if verbosity */ else if (!HDstrncmp(argv[i], "--logpath=", 10)) { mirror_log(NULL, V_INFO, "parsing 'logpath' (%s)", argv[i] + 10); @@ -456,7 +456,7 @@ error: * --------------------------------------------------------------------------- */ static void -wait_for_child(int sig) +wait_for_child(int H5_ATTR_UNUSED sig) { while (HDwaitpid(-1, NULL, WNOHANG) > 0) ; @@ -476,7 +476,7 @@ handle_requests(struct server_run *run) { int connfd = -1; /**/ char mybuf[H5FD_MIRROR_XMIT_OPEN_SIZE]; /**/ - int ret; /* general-purpose error-checking */ + ssize_t ret; /* general-purpose error-checking */ int pid; /* process ID of fork */ struct sigaction sa; int ret_value = 0; @@ -521,14 +521,13 @@ handle_requests(struct server_run *run) /* Read handshake from port connection. */ - ret = (int)HDread(connfd, &mybuf, H5FD_MIRROR_XMIT_OPEN_SIZE); - if (-1 == ret) { + if ((ret = HDread(connfd, &mybuf, H5FD_MIRROR_XMIT_OPEN_SIZE)) < 0) { mirror_log(run->loginfo, V_ERR, "read:%d", ret); goto error; } mirror_log(run->loginfo, V_INFO, "received %d bytes", ret); mirror_log(run->loginfo, V_ALL, "```"); - mirror_log_bytes(run->loginfo, V_ALL, ret, (const unsigned char *)mybuf); + mirror_log_bytes(run->loginfo, V_ALL, (size_t)ret, (const unsigned char *)mybuf); mirror_log(run->loginfo, V_ALL, "```"); /* Respond to handshake message. diff --git a/utils/mirror_vfd/mirror_writer.c b/utils/mirror_vfd/mirror_writer.c index d3f12de..5726db5 100644 --- a/utils/mirror_vfd/mirror_writer.c +++ b/utils/mirror_vfd/mirror_writer.c @@ -788,8 +788,7 @@ do_write(struct mirror_session *session, const unsigned char *xmit_buf) */ sum_bytes_written = 0; do { - nbytes_in_packet = HDread(session->sockfd, buf, H5FD_MIRROR_DATA_BUFFER_MAX); - if (-1 == nbytes_in_packet) { + if ((nbytes_in_packet = HDread(session->sockfd, buf, H5FD_MIRROR_DATA_BUFFER_MAX)) < 0) { mirror_log(session->loginfo, V_ERR, "can't read into databuffer"); reply_error(session, "can't read data buffer"); return -1; @@ -798,7 +797,7 @@ do_write(struct mirror_session *session, const unsigned char *xmit_buf) mirror_log(session->loginfo, V_INFO, "received %zd bytes", nbytes_in_packet); if (HEXDUMP_WRITEDATA) { mirror_log(session->loginfo, V_ALL, "DATA:\n```"); - mirror_log_bytes(session->loginfo, V_ALL, nbytes_in_packet, (const unsigned char *)buf); + mirror_log_bytes(session->loginfo, V_ALL, (size_t)nbytes_in_packet, (const unsigned char *)buf); mirror_log(session->loginfo, V_ALL, "```"); } @@ -859,8 +858,7 @@ receive_communique(struct mirror_session *session, struct sock_comm *comm) mirror_log(session->loginfo, V_INFO, "ready to receive"); /* TODO */ - read_ret = HDread(session->sockfd, comm->raw, H5FD_MIRROR_XMIT_BUFFER_MAX); - if (-1 == read_ret) { + if ((read_ret = HDread(session->sockfd, comm->raw, H5FD_MIRROR_XMIT_BUFFER_MAX)) < 0) { mirror_log(session->loginfo, V_ERR, "read:%zd", read_ret); goto error; } |