]> granicus.if.org Git - graphviz/commitdiff
gvgen: [nfc] remove mode argument to openFile
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 22 Jul 2021 02:18:49 +0000 (19:18 -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 gvgen.

cmd/tools/gvgen.c

index fbba4c501982e5e7e35b10880faa9461d8c975ad..c4e947aeb630691cb61ce0af223774761db17b28 100644 (file)
@@ -46,19 +46,13 @@ typedef struct {
 
 static char *cmd;
 
-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",
-               cmd, name, modestr);
+       fprintf(stderr, "%s: could not open file %s for writing\n", cmd, name);
        exit(1);
     }
     return fp;
@@ -358,7 +352,7 @@ static GraphType init(int argc, char *argv[], opts_t* opts)
            opts->name = optarg;
            break;
        case 'o':
-           opts->outfile = openFile(optarg, "w");
+           opts->outfile = openFile(optarg);
            break;
        case 'p':
            graphType = path;