From 6340e7959a273018c4bbbf99355e8f69340f4aa1 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Wed, 21 Jul 2021 19:17:48 -0700 Subject: [PATCH] gv2gml: [nfc] remove mode argument to openFile This function is only ever called with mode "w". This is the equivalent of 21a6f2e2f7e8a377977c7bdad1356591a25d516f for gv2gml. --- cmd/tools/gv2gml.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/cmd/tools/gv2gml.c b/cmd/tools/gv2gml.c index c26bcda2c..461434718 100644 --- a/cmd/tools/gv2gml.c +++ b/cmd/tools/gv2gml.c @@ -645,19 +645,14 @@ gv_to_gml(Agraph_t* G, FILE* outFile) fprintf (outFile, "]\n"); } -static FILE *openFile(const char *name, const char *mode) +static FILE *openFile(const char *name) { FILE *fp; - char *modestr; - fp = fopen(name, mode); + fp = fopen(name, "w"); if (!fp) { - if (*mode == 'r') - modestr = "reading"; - else - modestr = "writing"; - fprintf(stderr, "%s: could not open file %s for %s\n", - CmdName, name, modestr); + fprintf(stderr, "%s: could not open file %s for writing\n", + CmdName, name); perror(name); exit(1); } @@ -699,7 +694,7 @@ static void initargs(int argc, char **argv) case 'o': if (outFile != NULL) fclose(outFile); - outFile = openFile(optarg, "w"); + outFile = openFile(optarg); break; case ':': fprintf(stderr, "%s: option -%c missing parameter\n", CmdName, optopt); -- 2.40.0