aboutgitcodebugslistschat
path: root/util.h
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-04-05 11:51:47 +0200
committerStefano Brivio <sbrivio@redhat.com>2022-04-07 11:44:35 +0200
commiteb3d3f367ea09b89d54f177ded1e874611d1020f (patch)
tree31fea867bba5f73506352c8a1188fa1309669cd2 /util.h
parentbb76470090dc21540e70c3417fe0227c5a62cce2 (diff)
downloadpasst-eb3d3f367ea09b89d54f177ded1e874611d1020f.tar
passt-eb3d3f367ea09b89d54f177ded1e874611d1020f.tar.gz
passt-eb3d3f367ea09b89d54f177ded1e874611d1020f.tar.bz2
passt-eb3d3f367ea09b89d54f177ded1e874611d1020f.tar.lz
passt-eb3d3f367ea09b89d54f177ded1e874611d1020f.tar.xz
passt-eb3d3f367ea09b89d54f177ded1e874611d1020f.tar.zst
passt-eb3d3f367ea09b89d54f177ded1e874611d1020f.zip
treewide: Argument cannot be negative, CWE-687
Actually harmless. Reported by Coverity. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'util.h')
-rw-r--r--util.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/util.h b/util.h
index 91ce3e0..5172bf6 100644
--- a/util.h
+++ b/util.h
@@ -58,6 +58,18 @@ void trace_init(int enable);
#define TMPDIR "/tmp"
#endif
+#define FWRITE(path, buf, str) \
+ do { \
+ int flags = O_WRONLY | O_CLOEXEC; \
+ int fd = open(path, flags); \
+ \
+ if (fd < 0 || \
+ write(fd, buf, strlen(buf)) != (int)strlen(buf)) \
+ warn(str); \
+ if (fd >= 0) \
+ close(fd); \
+ } while (0)
+
#define V4 0
#define V6 1
#define IP_VERSIONS 2