[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 22/63: tool_parse_cfg: Avoid 2 fopen() for WIN32
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 22/63: tool_parse_cfg: Avoid 2 fopen() for WIN32 |
Date: |
Fri, 07 Jun 2019 18:36:44 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit 8144ba38c383718355d8af2ed8330414edcbbc83
Author: Gisle Vanem <address@hidden>
AuthorDate: Thu May 23 17:13:39 2019 +0200
tool_parse_cfg: Avoid 2 fopen() for WIN32
Using the memdebug.h mem-leak feature, I noticed 2 calls like:
FILE tool_parsecfg.c:70
fopen("c:\Users\Gisle\AppData\Roaming\_curlrc","rt")
FILE tool_parsecfg.c:114
fopen("c:\Users\Gisle\AppData\Roaming\_curlrc","rt")
No need for 'fopen(), 'fclose()' and a 'fopen()' yet again.
---
src/tool_parsecfg.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/tool_parsecfg.c b/src/tool_parsecfg.c
index e36b06c23..683e25ac1 100644
--- a/src/tool_parsecfg.c
+++ b/src/tool_parsecfg.c
@@ -46,7 +46,7 @@ static char *my_get_line(FILE *fp);
/* return 0 on everything-is-fine, and non-zero otherwise */
int parseconfig(const char *filename, struct GlobalConfig *global)
{
- FILE *file;
+ FILE *file = NULL;
char filebuffer[512];
bool usedarg = FALSE;
int rc = 0;
@@ -69,7 +69,6 @@ int parseconfig(const char *filename, struct GlobalConfig
*global)
*/
file = fopen(filebuffer, FOPEN_READTEXT);
if(file != NULL) {
- fclose(file);
filename = filebuffer;
}
else {
@@ -110,7 +109,9 @@ int parseconfig(const char *filename, struct GlobalConfig
*global)
#endif
}
- if(strcmp(filename, "-"))
+ if(file != NULL) /* WIN32: no need to fopen() again */
+ ;
+ else if(strcmp(filename, "-"))
file = fopen(filename, FOPEN_READTEXT);
else
file = stdin;
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [gnurl] 11/63: sasl: Implement SASL authorisation identity via CURLOPT_SASL_AUTHZID, (continued)
- [GNUnet-SVN] [gnurl] 11/63: sasl: Implement SASL authorisation identity via CURLOPT_SASL_AUTHZID, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 10/63: tests: add support to test against OpenSSH for Windows, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 08/63: examples: fix "clarify calculation precedence" warnings, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 02/63: configure/cmake: check for if_nametoindex(), gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 13/63: examples: Added SASL PLAIN authorisation identity (authzid) examples, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 09/63: bump: start on the next release, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 15/63: url: fix bad #ifdef, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 14/63: Revert "progress: CURL_DISABLE_PROGRESS_METER", gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 23/63: winbuild: Use two space indentation, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 17/63: config-win32: add support for if_nametoindex and getsockname, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 22/63: tool_parse_cfg: Avoid 2 fopen() for WIN32,
gnunet <=
- [GNUnet-SVN] [gnurl] 39/63: parse_proxy: make sure portptr is initialized, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 29/63: Revert all SASL authzid (new feature) commits, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 21/63: md4: include the mbedtls config.h to get the MD4 info, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 07/63: hiperfifo: remove unused variable, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 12/63: curl: --sasl-authzid added to support CURLOPT_SASL_AUTHZID from the tool, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 25/63: Fix typo., gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 37/63: conncache: make "bundles" per host name when doing proxy tunnels, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 35/63: curl-win32.h: Enable Unix Domain Sockets based on the Windows SDK version, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 42/63: appveyor: add support for other build systems, gnunet, 2019/06/07
- [GNUnet-SVN] [gnurl] 43/63: appveyor: add Visual Studio solution build, gnunet, 2019/06/07