]> granicus.if.org Git - graphviz/commitdiff
common: cast stat size results, squashing -Wsign-conversion warnings
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 21 May 2022 03:08:35 +0000 (20:08 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 23 May 2022 05:00:30 +0000 (22:00 -0700)
The `st_size` field coming out of the `stat` call is always non-negative.

lib/common/psusershape.c

index a5cae11fad5aed4f77b7999ea786daa58b9ec735..abccefc746f293237ecdbf3a339db36a77f3fb74 100644 (file)
@@ -74,9 +74,9 @@ static usershape_t *user_init(const char *str)
        us->name = str;
        us->macro_id = N_EPSF_files++;
        fstat(fileno(fp), &statbuf);
-       contents = us->data = N_GNEW(statbuf.st_size + 1, char);
+       contents = us->data = N_GNEW((size_t)statbuf.st_size + 1, char);
        fseek(fp, 0, SEEK_SET);
-       rc = fread(contents, statbuf.st_size, 1, fp);
+       rc = fread(contents, (size_t)statbuf.st_size, 1, fp);
        if (rc == 1) {
             contents[statbuf.st_size] = '\0';
             dtinsert(EPSF_contents, us);