[tin-dev] [PATCH] silence some gcc -fanalyzer false positives
Urs Janßen
urs at tin.org
Wed Sep 20 08:06:36 CEST 2023
--- src/post.c 2023-08-23 15:40:43.299384785 +0200
+++ src/post.c 2023-09-20 07:56:05.952588388 +0200
@@ -4841,6 +4841,9 @@
char line[HEADER_LEN];
int num_x_hdrs = 0;
int i;
+#ifndef DONT_HAVE_PIPING
+ t_bool pipe = FALSE;
+#endif /* !DONT_HAVE_PIPING */
if (!headers)
return;
@@ -4866,10 +4869,14 @@
if (file[0] == '!') {
if ((fp = popen(file + 1, "r")) == NULL)
return;
+ pipe = TRUE;
}
+ if (!pipe)
#endif /* !DONT_HAVE_PIPING */
- if (!fp && ((fp = fopen(file, "r")) == NULL))
- return;
+ {
+ if ((fp = fopen(file, "r")) == NULL)
+ return;
+ }
while (fgets(line, (int) sizeof(line), fp) != NULL) {
if (line[0] != '\n' && line[0] != '#') {
@@ -4898,7 +4905,7 @@
}
#ifndef DONT_HAVE_PIPING
- if (file[0] == '!')
+ if (pipe)
pclose(fp);
else
#endif /* !DONT_HAVE_PIPING */
@@ -4922,6 +4929,9 @@
char file[PATH_LEN];
char line[HEADER_LEN];
int wrote = 0;
+#ifndef DONT_HAVE_PIPING
+ t_bool pipe = FALSE;
+#endif /* !DONT_HAVE_PIPING */
if (!body || !fp_out)
return 0;
@@ -4945,18 +4955,21 @@
if (file[0] == '!') {
if ((fp = popen(file + 1, "r")) == NULL)
return 0;
+ pipe = TRUE;
}
+ if (!pipe)
#endif /* !DONT_HAVE_PIPING */
-
- if (!fp && ((fp = fopen(file, "r")) == NULL))
- return 0;
+ {
+ if ((fp = fopen(file, "r")) == NULL)
+ return 0;
+ }
while (fgets(line, (int) sizeof(line), fp) != NULL) {
fputs(line, fp_out);
wrote++;
}
#ifndef DONT_HAVE_PIPING
- if (file[0] == '!')
+ if (pipe)
pclose(fp);
else
#endif /* !DONT_HAVE_PIPING */
=== modified file 'include/tin.h'
--- include/tin.h 2023-08-10 06:21:49 +0000
+++ include/tin.h 2023-09-20 05:56:56 +0000
@@ -853,11 +853,11 @@
/*
* safe strcpy into fixed-legth buffer
*/
-#if 1
+#if 0
# define STRCPY(dst, src) (strncpy(dst, src, sizeof(dst) - 1), dst[sizeof(dst) - 1] = '\0')
#else
# define STRCPY(dst, src) (*(dst) = '\0', strncat(dst, src, sizeof(dst) - 1))
-#endif /* 1 */
+#endif /* 0 */
#define STRCMPEQ(s1, s2) (strcmp((s1), (s2)) == 0)
#define STRNCMPEQ(s1, s2, n) (strncmp((s1), (s2), n) == 0)
More information about the tin-dev
mailing list