mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: warn when casting a fixed array (use &arr[0]
instead) (#8787)
This commit is contained in:
@@ -93,8 +93,8 @@ pub fn ls(path string) ?[]string {
|
||||
if isnil(ent) {
|
||||
break
|
||||
}
|
||||
bptr := byteptr(ent.d_name)
|
||||
unsafe {
|
||||
bptr := byteptr(&ent.d_name[0])
|
||||
if bptr[0] == 0 || (bptr[0] == `.` && bptr[1] == 0)
|
||||
|| (bptr[0] == `.` && bptr[1] == `.` && bptr[2] == 0) {
|
||||
continue
|
||||
@@ -169,8 +169,8 @@ pub fn exec(cmd string) ?Result {
|
||||
buf := [4096]byte{}
|
||||
mut res := strings.new_builder(1024)
|
||||
unsafe {
|
||||
for C.fgets(charptr(buf), 4096, f) != 0 {
|
||||
bufbp := byteptr(buf)
|
||||
bufbp := &buf[0]
|
||||
for C.fgets(charptr(bufbp), 4096, f) != 0 {
|
||||
res.write_bytes(bufbp, vstrlen(bufbp))
|
||||
}
|
||||
}
|
||||
@@ -210,11 +210,11 @@ pub fn (mut c Command) read_line() string {
|
||||
buf := [4096]byte{}
|
||||
mut res := strings.new_builder(1024)
|
||||
unsafe {
|
||||
for C.fgets(charptr(buf), 4096, c.f) != 0 {
|
||||
bufbp := byteptr(buf)
|
||||
bufbp := &buf[0]
|
||||
for C.fgets(charptr(bufbp), 4096, c.f) != 0 {
|
||||
len := vstrlen(bufbp)
|
||||
for i in 0 .. len {
|
||||
if int(bufbp[i]) == `\n` {
|
||||
if bufbp[i] == `\n` {
|
||||
res.write_bytes(bufbp, i)
|
||||
return res.str()
|
||||
}
|
||||
|
Reference in New Issue
Block a user