summaryrefslogtreecommitdiff
path: root/src/tools/oftp
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2026-07-10 17:09:58 +0200
committerSander Vrijders <sander@ouroboros.rocks>2026-07-19 11:44:35 +0200
commit8228212b0c4e1fe313d0a171f61fd103554bf5ab (patch)
tree515203f83eb6718df48af7d090ccaa6a3622d293 /src/tools/oftp
parenteeea0006825ac404e20656e148c2db47b454dd6a (diff)
downloadouroboros-8228212b0c4e1fe313d0a171f61fd103554bf5ab.tar.gz
ouroboros-8228212b0c4e1fe313d0a171f61fd103554bf5ab.zip
tools: Key oftp cleanup on path arguments
The cleanup guards compared the stream against the stdin/stdout globals, which tripped the clang static analyzer. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/tools/oftp')
-rw-r--r--src/tools/oftp/oftp.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/tools/oftp/oftp.c b/src/tools/oftp/oftp.c
index 1ae99403..2504393a 100644
--- a/src/tools/oftp/oftp.c
+++ b/src/tools/oftp/oftp.c
@@ -65,9 +65,11 @@ static void apply_rto_min_env(int fd)
env = getenv("OFTP_FRCT_RTO_MIN");
if (env == NULL)
return;
+
v = strtol(env, NULL, 10);
if (v <= 0)
return;
+
if (fccntl(fd, FRCTSRTOMIN, (time_t) v) < 0)
fprintf(stderr,
"oftp: failed to set RTO_MIN=%ld ns\n", v);
@@ -81,9 +83,11 @@ static void apply_stream_ring_sz_env(int fd)
env = getenv("OFTP_FRCT_STREAM_RING_SZ");
if (env == NULL)
return;
+
v = strtol(env, NULL, 10);
if (v <= 0)
return;
+
if (fccntl(fd, FRCTSRRINGSZ, (size_t) v) < 0)
fprintf(stderr,
"oftp: failed to set STREAM_RING_SZ=%ld\n", v);
@@ -301,7 +305,7 @@ static int server_main(const char * outpath)
fd = flow_accept(&qs, NULL);
if (fd < 0) {
fprintf(stderr, "flow_accept failed: %d\n", fd);
- if (out != stdout)
+ if (outpath != NULL)
fclose(out);
return 1;
}
@@ -311,7 +315,7 @@ static int server_main(const char * outpath)
"oftp: rejecting non-stream flow (service=%u)\n",
qs.service);
flow_dealloc(fd);
- if (out != stdout) {
+ if (outpath != NULL) {
fclose(out);
unlink(outpath);
}
@@ -325,7 +329,7 @@ static int server_main(const char * outpath)
flow_dealloc(fd);
- if (out != stdout) {
+ if (outpath != NULL) {
fclose(out);
/* Drop the half-written file on abort/interrupt. */
if (rc != 0)
@@ -358,7 +362,7 @@ static int client_main(const char * name,
fd = flow_alloc(name, &qs, NULL);
if (fd < 0) {
fprintf(stderr, "flow_alloc failed: %d\n", fd);
- if (in != stdin)
+ if (inpath != NULL)
fclose(in);
return 2;
}
@@ -370,7 +374,7 @@ static int client_main(const char * name,
flow_dealloc(fd);
- if (in != stdin)
+ if (inpath != NULL)
fclose(in);
return rc;