mirror of
https://github.com/reactos/syzkaller.git
synced 2024-11-23 03:19:51 +00:00
all: don't compare string len with 0
For strings it's more readable to compare the string itself with "", instead of comparing len with 0. Fix all such cases. Update #1876
This commit is contained in:
parent
74cb4e09a5
commit
fcb219b67e
@ -363,7 +363,7 @@ func handleBug(c context.Context, w http.ResponseWriter, r *http.Request) error
|
||||
Caption: fmt.Sprintf("Crashes (%d)", bug.NumCrashes),
|
||||
}
|
||||
for _, crash := range crashesTable.Crashes {
|
||||
if len(crash.Maintainers) != 0 {
|
||||
if crash.Maintainers != "" {
|
||||
crashesTable.HasMaintainers = true
|
||||
break
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func TestCompilerIdentity(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("failed: %v", err)
|
||||
}
|
||||
if len(id) == 0 {
|
||||
if id == "" {
|
||||
t.Fatalf("identity is empty")
|
||||
}
|
||||
if strings.Contains(id, "\n") {
|
||||
|
@ -249,7 +249,7 @@ func (ctx *context) emitCall(w *bytes.Buffer, call prog.ExecCall, ci int, haveCo
|
||||
}
|
||||
fmt.Fprintf(w, ");")
|
||||
comment := ctx.target.AnnotateCall(call)
|
||||
if len(comment) != 0 {
|
||||
if comment != "" {
|
||||
fmt.Fprintf(w, " /* %s */", comment)
|
||||
}
|
||||
fmt.Fprintf(w, "\n")
|
||||
|
@ -352,7 +352,7 @@ func isSupportedOpenAt(c *prog.Syscall) (bool, string) {
|
||||
var err error
|
||||
|
||||
fname, ok := extractStringConst(c.Args[1].Type)
|
||||
if !ok || len(fname) == 0 || fname[0] != '/' {
|
||||
if !ok || fname == "" || fname[0] != '/' {
|
||||
return true, ""
|
||||
}
|
||||
|
||||
@ -415,7 +415,7 @@ func extractStringConst(typ prog.Type) (string, bool) {
|
||||
return "", false
|
||||
}
|
||||
v := str.Values[0]
|
||||
for len(v) != 0 && v[len(v)-1] == 0 {
|
||||
for v != "" && v[len(v)-1] == 0 {
|
||||
v = v[:len(v)-1] // string terminating \x00
|
||||
}
|
||||
return v, true
|
||||
|
@ -249,7 +249,7 @@ func (r *randGen) flags(vv []uint64, bitmask bool, oldVal uint64) uint64 {
|
||||
|
||||
func (r *randGen) filename(s *state, typ *BufferType) string {
|
||||
fn := r.filenameImpl(s)
|
||||
if len(fn) != 0 && fn[len(fn)-1] == 0 {
|
||||
if fn != "" && fn[len(fn)-1] == 0 {
|
||||
panic(fmt.Sprintf("zero-terminated filename: %q", fn))
|
||||
}
|
||||
if escapingFilename(fn) {
|
||||
@ -284,7 +284,7 @@ func (r *randGen) filenameImpl(s *state) string {
|
||||
dir := "."
|
||||
if r.oneOf(2) && len(s.files) != 0 {
|
||||
dir = r.randFromMap(s.files)
|
||||
if len(dir) > 0 && dir[len(dir)-1] == 0 {
|
||||
if dir != "" && dir[len(dir)-1] == 0 {
|
||||
dir = dir[:len(dir)-1]
|
||||
}
|
||||
if r.oneOf(10) && filepath.Clean(dir)[0] != '.' {
|
||||
|
@ -689,7 +689,7 @@ func (mgr *Manager) saveCrash(crash *Crash) bool {
|
||||
}
|
||||
}
|
||||
osutil.WriteFile(filepath.Join(dir, fmt.Sprintf("log%v", oldestI)), crash.Output)
|
||||
if len(mgr.cfg.Tag) > 0 {
|
||||
if mgr.cfg.Tag != "" {
|
||||
osutil.WriteFile(filepath.Join(dir, fmt.Sprintf("tag%v", oldestI)), []byte(mgr.cfg.Tag))
|
||||
}
|
||||
if len(crash.Report.Report) > 0 {
|
||||
@ -836,7 +836,7 @@ func (mgr *Manager) saveRepro(res *repro.Result, stats *repro.Stats, hub bool) {
|
||||
log.Logf(0, "failed to write crash: %v", err)
|
||||
}
|
||||
osutil.WriteFile(filepath.Join(dir, "repro.prog"), append([]byte(opts), prog...))
|
||||
if len(mgr.cfg.Tag) > 0 {
|
||||
if mgr.cfg.Tag != "" {
|
||||
osutil.WriteFile(filepath.Join(dir, "repro.tag"), []byte(mgr.cfg.Tag))
|
||||
}
|
||||
if len(rep.Output) > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user