Skip to content

Commit

Permalink
fs/vfs/main.cc: fix gcc 11 build error
Browse files Browse the repository at this point in the history
In fs/vfs/main.cc we have bootfs_start, which was defined as a single
character (extern char bootfs_start) but was really treated as the
beginning of a longer memory area. Gcc 11 can recognize that we access
beyond this single character, and fail the compilation.

To work around this problem, we declare bootfs_start as
	extern char bootfs_start[]

Little needs to be changed besides this - except changing
&bootfs_start + offset - which gcc doesn't like, to
&bootfs_start[offset].

Signed-off-by: Nadav Har'El <nyh@scylladb.com>
Message-Id: <20210614062057.1998552-8-nyh@scylladb.com>
  • Loading branch information
nyh authored and wkozaczuk committed Jun 14, 2021
1 parent b589e38 commit b3965a9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/vfs/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2197,7 +2197,7 @@ struct bootfs_metadata {
char name[BOOTFS_PATH_MAX];
};

extern char bootfs_start;
extern char bootfs_start[];

int ramfs_set_file_data(struct vnode *vp, const void *data, size_t size);
void unpack_bootfs(void)
Expand All @@ -2223,7 +2223,7 @@ void unpack_bootfs(void)
if (md[i].type == bootfs_file_type::symlink) {
// This is a symbolic link record. The file's content is the
// target path, and we assume ends with a null.
if (symlink(&bootfs_start + md[i].offset, md[i].name) != 0) {
if (symlink(&bootfs_start[md[i].offset], md[i].name) != 0) {
kprintf("couldn't symlink %s: %d\n", md[i].name, errno);
sys_panic("unpack_bootfs failed");
}
Expand All @@ -2250,7 +2250,7 @@ void unpack_bootfs(void)
}

struct vnode *vp = fp->f_dentry->d_vnode;
ret = ramfs_set_file_data(vp, &bootfs_start + md[i].offset, md[i].size);
ret = ramfs_set_file_data(vp, &bootfs_start[md[i].offset], md[i].size);
if (ret) {
kprintf("ramfs_set_file_data failed, ret = %d\n", ret);
sys_panic("unpack_bootfs failed");
Expand Down

0 comments on commit b3965a9

Please sign in to comment.