Skip to content

Commit

Permalink
set nil as the initial value of the struct reference type field
Browse files Browse the repository at this point in the history
  • Loading branch information
shove70 committed Nov 20, 2023
1 parent 50b00e7 commit be0e07d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions kernel/modules/file/file.v
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub fn syscall_ppoll(_ voidptr, fds &PollFD, nfds u64, tmo_p &time.TimeSpec, sig
return ret, 0
}

mut timer := &time.Timer(unsafe{ nil })
mut timer := &time.Timer(unsafe { nil })

if voidptr(tmo_p) != unsafe { nil } {
mut target_time := *tmo_p
Expand Down Expand Up @@ -204,7 +204,7 @@ pub fn (mut this Handle) ioctl(request u64, argp voidptr) ?int {

pub struct FD {
pub mut:
handle &Handle
handle &Handle = unsafe { nil }
flags int
}

Expand Down
14 changes: 7 additions & 7 deletions kernel/modules/fs/vfs.v
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ mut:

pub struct VFSNode {
pub mut:
mountpoint &VFSNode
redir &VFSNode
resource &resource.Resource
filesystem &FileSystem
mountpoint &VFSNode = unsafe { nil }
redir &VFSNode = unsafe { nil }
resource &resource.Resource = unsafe { nil }
filesystem &FileSystem = unsafe { nil }
name string
parent &VFSNode
children &map[string]&VFSNode
parent &VFSNode = unsafe { nil }
children &map[string]&VFSNode = unsafe { nil }
symlink_target string
}

Expand Down Expand Up @@ -526,7 +526,7 @@ pub fn syscall_openat(_ voidptr, dirfd int, _path charptr, flags int, mode int)
return errno.err, errno.get()
}

if !stat.isdir(node.resource.stat.mode) && (flags & resource.o_directory != 0) {
if !stat.isdir(node.resource.stat.mode) && flags & resource.o_directory != 0 {
return errno.err, errno.enotdir
}

Expand Down
4 changes: 2 additions & 2 deletions kernel/modules/memory/mmap/mmap.v
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ pub const (

pub struct MmapRangeLocal {
pub mut:
pagemap &memory.Pagemap
global &MmapRangeGlobal
pagemap &memory.Pagemap = unsafe { nil }
global &MmapRangeGlobal = unsafe { nil }
base u64
length u64
offset i64
Expand Down
4 changes: 2 additions & 2 deletions kernel/modules/proc/proc.v
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct Process {
pub mut:
pid int
ppid int
pagemap &memory.Pagemap
pagemap &memory.Pagemap = unsafe { nil }
thread_stack_top u64
threads []&Thread
fds_lock klock.Lock
Expand Down Expand Up @@ -52,7 +52,7 @@ pub mut:
tid int
is_in_queue bool
l klock.Lock
process &Process
process &Process = unsafe { nil }
gpr_state cpulocal.GPRState
gs_base u64
fs_base u64
Expand Down
4 changes: 2 additions & 2 deletions kernel/modules/socket/unix/unix.v
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ pub mut:

connection_event eventstruct.Event
connected bool
peer &UnixSocket
peer &UnixSocket = unsafe { nil }

data &u8
data &u8 = unsafe { nil }
read_ptr u64
write_ptr u64
capacity u64
Expand Down

0 comments on commit be0e07d

Please sign in to comment.