]> granicus.if.org Git - graphviz/commitdiff
gml2gv: [nfc] remove mode argument to openFile
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 22 Jul 2021 02:14:51 +0000 (19:14 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 28 Jul 2021 02:53:30 +0000 (19:53 -0700)
This function is only ever called with mode "w". This is the equivalent of
21a6f2e2f7e8a377977c7bdad1356591a25d516f for gml2gv.

cmd/tools/gml2gv.c

index da3de133d75915eec4d98ecefef3bebb872de505..3ee0c40658486d0d96747b75e746af95e0cbec24 100644 (file)
@@ -51,19 +51,14 @@ static FILE *getFile(void)
     return rv;
 }
 
-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);
     }
@@ -113,7 +108,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 argument\n", CmdName, optopt);