Forgot to initialize ObjId structure in newfs

This commit is contained in:
Ali Mashtizadeh 2023-09-10 20:56:37 -04:00
parent b39acb2afd
commit fc665b5f5b

View File

@ -112,6 +112,7 @@ ObjID *AddFile(const char *file)
ObjID *id = malloc(sizeof(ObjID)); ObjID *id = malloc(sizeof(ObjID));
BNode node; BNode node;
memset(id, 0, sizeof(*id));
memset(&node, 0, sizeof(node)); memset(&node, 0, sizeof(node));
memcpy(node.magic, BNODE_MAGIC, 8); memcpy(node.magic, BNODE_MAGIC, 8);
node.versionMajor = O2FS_VERSION_MAJOR; node.versionMajor = O2FS_VERSION_MAJOR;
@ -209,6 +210,7 @@ ObjID *AddDirectory()
int i; int i;
uint64_t off; uint64_t off;
memset(id, 0, sizeof(*id));
memset(&node, 0, sizeof(node)); memset(&node, 0, sizeof(node));
memcpy(node.magic, BNODE_MAGIC, 8); memcpy(node.magic, BNODE_MAGIC, 8);
node.versionMajor = O2FS_VERSION_MAJOR; node.versionMajor = O2FS_VERSION_MAJOR;
@ -262,6 +264,9 @@ int main(int argc, char * const *argv)
int ch; int ch;
int status; int status;
// Sanity check
assert(sizeof(BDirEntry) == 512);
struct option longopts[] = { struct option longopts[] = {
{ "manifest", required_argument, NULL, 'm' }, { "manifest", required_argument, NULL, 'm' },
{ "size", required_argument, NULL, 's' }, { "size", required_argument, NULL, 's' },