Skip to content

Commit 2f66be2

Browse files
committed
Add minimal-ish example of what causes deadcode in smtprc.
1 parent d660f1a commit 2f66be2

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include <string.h>
2+
#include <assert.h>
3+
#include <stdlib.h>
4+
#include <stdio.h>
5+
6+
struct options
7+
{
8+
char *ip_range;
9+
};
10+
11+
struct options o;
12+
13+
int get_ip_range(int *iprange)
14+
{
15+
char *r = iprange;
16+
17+
while (*r++)
18+
{
19+
*r = '\0';
20+
assert(1);
21+
}
22+
23+
return (0);
24+
}
25+
26+
int main()
27+
{
28+
char *optarg = "was from unistd.h";
29+
o.ip_range = malloc((strlen(optarg) + 1) * sizeof(char));
30+
strncpy(o.ip_range, optarg, strlen(optarg));
31+
o.ip_range[strlen(optarg)] = '\0';
32+
get_ip_range(o.ip_range);
33+
}

0 commit comments

Comments
 (0)