Skip to content

Commit cce87c7

Browse files
Remove dead code
1 parent 1437ed4 commit cce87c7

3 files changed

Lines changed: 4 additions & 23 deletions

File tree

src/config.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ int add_trusted_cert(struct vpn_config *cfg, const char *digest)
100100

101101
new = malloc(sizeof(struct x509_digest));
102102
if (new == NULL)
103-
return ERR_CFG_NO_MEM;
103+
return -errno;
104104

105105
new->next = NULL;
106106
strncpy(new->data, digest, SHA256STRLEN - 1);
@@ -194,7 +194,7 @@ int load_config(struct vpn_config *cfg, const char *filename)
194194

195195
file = fopen(filename, "r");
196196
if (file == NULL) {
197-
ret = ERR_CFG_SEE_ERRNO;
197+
ret = -errno;
198198
goto err_return;
199199
}
200200

@@ -482,7 +482,7 @@ int load_config(struct vpn_config *cfg, const char *filename)
482482
}
483483
}
484484
if (ferror(file))
485-
ret = ERR_CFG_SEE_ERRNO;
485+
ret = -errno;
486486

487487
err_free:
488488
free(line);

src/config.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,6 @@
2525
#include <stdint.h>
2626
#include <string.h>
2727

28-
#define ERR_CFG_UNKNOWN -1
29-
#define ERR_CFG_SEE_ERRNO -2
30-
#define ERR_CFG_EMPTY_FILE -3
31-
#define ERR_CFG_NO_MEM -4
32-
#define ERR_CFG_CANNOT_READ -5
33-
34-
static inline const char *err_cfg_str(int code)
35-
{
36-
if (code == ERR_CFG_SEE_ERRNO)
37-
return strerror(errno);
38-
else if (code == ERR_CFG_EMPTY_FILE)
39-
return "Empty file";
40-
else if (code == ERR_CFG_NO_MEM)
41-
return "Not enough memory";
42-
else if (code == ERR_CFG_CANNOT_READ)
43-
return "Cannot read file";
44-
return "unknown";
45-
}
46-
4728
#if HAVE_USR_SBIN_PPPD
4829
#define PPP_DAEMON "pppd"
4930
#else

src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ int main(int argc, char *argv[])
668668
log_debug("Loaded configuration file \"%s\".\n", config_file);
669669
else
670670
log_warn("Could not load configuration file \"%s\" (%s).\n",
671-
config_file, err_cfg_str(ret));
671+
config_file, strerror(-ret));
672672
}
673673
if (cli_cfg.password_set) {
674674
if (cli_cfg.password[0] == '\0')

0 commit comments

Comments
 (0)