aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/hs_apps/vcl/sock_test.h
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-10-18 16:52:48 -0700
committerFlorin Coras <florin.coras@gmail.com>2020-10-19 15:55:56 +0000
commit710d78074e07ffb5006ad01a0da4c1b6dc3de38b (patch)
treef374fb0a08f3fab4b7f8596eca6596b3693b70d5 /src/plugins/hs_apps/vcl/sock_test.h
parent585c86ae8bcb650b388439a5c3fbb3a0be45802c (diff)
hsa: refactor socket client app
Type: refactor Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I020e62e1ad929742e1b14b807de3a6f04a9e496f
Diffstat (limited to 'src/plugins/hs_apps/vcl/sock_test.h')
-rw-r--r--src/plugins/hs_apps/vcl/sock_test.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/plugins/hs_apps/vcl/sock_test.h b/src/plugins/hs_apps/vcl/sock_test.h
index 94aa08305a8..d4283efc3a4 100644
--- a/src/plugins/hs_apps/vcl/sock_test.h
+++ b/src/plugins/hs_apps/vcl/sock_test.h
@@ -38,11 +38,15 @@
errno = -_rv; \
printf ("\nERROR: " _fn " failed (errno = %d)!\n", -_rv); \
}
-#define stfail(_fn, _rv) \
+#define stabrt(_fmt, _args...) \
+{ \
+ printf ("\nERROR: " _fmt "\n", ##_args); \
+ exit (1); \
+}
+#define stfail(_fn) \
{ \
- errno = -_rv; \
perror ("ERROR when calling " _fn); \
- printf ("\nERROR: " _fn " failed (errno = %d)!\n", -_rv); \
+ printf ("\nERROR: " _fn " failed (errno = %d)!\n", errno); \
exit (1); \
}
@@ -71,10 +75,9 @@ sock_test_read (int fd, uint8_t * buf, uint32_t nbytes,
((rx_bytes < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))));
if (rx_bytes < 0)
- {
- stfail ("sock_test_read()", -errno);
- }
- else if (stats)
+ stfail ("sock_test_read()");
+
+ if (stats)
stats->rx_bytes += rx_bytes;
return (rx_bytes);
@@ -120,10 +123,9 @@ sock_test_write (int fd, uint8_t * buf, uint32_t nbytes,
while (tx_bytes != nbytes);
if (tx_bytes < 0)
- {
- stfail ("sock_test_write()", -errno);
- }
- else if (stats)
+ stfail ("sock_test_write()");
+
+ if (stats)
stats->tx_bytes += tx_bytes;
return (tx_bytes);