mirror of
https://code.blicky.net/yorhel/ncdu.git
synced 2026-01-13 01:08:41 -09:00
Avoid using extension of variable length array folded to constant array
(cherry picked from commit 2faefc3b24)
This commit is contained in:
parent
61d268764d
commit
53e5080d9a
1 changed files with 3 additions and 4 deletions
|
|
@ -111,8 +111,7 @@ int has_cachedir_tag(const char *name) {
|
||||||
static int path_l = 1024;
|
static int path_l = 1024;
|
||||||
static char *path = NULL;
|
static char *path = NULL;
|
||||||
int l;
|
int l;
|
||||||
const size_t signature_l = sizeof CACHEDIR_TAG_SIGNATURE - 1;
|
char buf[sizeof CACHEDIR_TAG_SIGNATURE - 1];
|
||||||
char buf[signature_l];
|
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int match = 0;
|
int match = 0;
|
||||||
|
|
||||||
|
|
@ -131,8 +130,8 @@ int has_cachedir_tag(const char *name) {
|
||||||
f = fopen(path, "rb");
|
f = fopen(path, "rb");
|
||||||
|
|
||||||
if(f != NULL) {
|
if(f != NULL) {
|
||||||
match = ((fread(buf, 1, signature_l, f) == signature_l) &&
|
match = ((fread(buf, 1, sizeof buf, f) == sizeof buf) &&
|
||||||
!memcmp(buf, CACHEDIR_TAG_SIGNATURE, signature_l));
|
!memcmp(buf, CACHEDIR_TAG_SIGNATURE, sizeof buf));
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
return match;
|
return match;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue