mirror of
https://github.com/hanzoai/visor.git
synced 2026-09-24 17:04:14 +00:00
Fix more printf findings
These are a combination of: * Non-constant string passed as format string * Mismatched format directive and argument type * Mismatched format directive and argument count PiperOrigin-RevId: 885802832
This commit is contained in:
committed by
gVisor bot
parent
f89c6d5a2a
commit
1cf4729bcc
@@ -351,7 +351,7 @@ func (c *Client) SndRcvMessage(m MID, payloadLen uint32, reqMarshal marshalFunc,
|
||||
// Copy it into the caller's buffer.
|
||||
numFDCopied := copy(respFDs, rcvFDs)
|
||||
if numFDCopied < numRcvFDs {
|
||||
log.Warningf("%d unexpected FDs were donated by the server, wanted", numRcvFDs-numFDCopied, wantFDs)
|
||||
log.Warningf("%d unexpected FDs were donated by the server, wanted %d", numRcvFDs-numFDCopied, wantFDs)
|
||||
closeFDs(rcvFDs[numFDCopied:])
|
||||
}
|
||||
if numFDCopied < wantFDs {
|
||||
|
||||
@@ -162,7 +162,7 @@ func doLeakCheck() {
|
||||
skip = o.LeakCheckDisabled()
|
||||
}
|
||||
if skip {
|
||||
log.Debugf(obj.LeakMessage())
|
||||
log.Debugf("%s", obj.LeakMessage())
|
||||
continue
|
||||
}
|
||||
msg += obj.LeakMessage() + "\n"
|
||||
@@ -174,6 +174,6 @@ func doLeakCheck() {
|
||||
if leakCheckPanicEnabled() {
|
||||
panic(msg)
|
||||
}
|
||||
log.Warningf(msg)
|
||||
log.Warningf("%s", msg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ func (fsType FilesystemType) GetFilesystem(ctx context.Context, vfsObj *vfs.Virt
|
||||
defer fuseFDGeneric.DecRef(ctx)
|
||||
fuseFD, ok := fuseFDGeneric.Impl().(*DeviceFD)
|
||||
if !ok {
|
||||
log.Warningf("%s.GetFilesystem: device FD is %T, not a FUSE device", fsType.Name, fuseFDGeneric)
|
||||
log.Warningf("%s.GetFilesystem: device FD is %T, not a FUSE device", fsType.Name(), fuseFDGeneric)
|
||||
return nil, nil, linuxerr.EINVAL
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ func (fstype FilesystemType) GetFilesystem(ctx context.Context, vfsObj *vfs.Virt
|
||||
// as Linux allocates memory in terms of Page size.
|
||||
maxSizeInPages, ok = hostarch.ToPagesRoundUp(maxSizeInBytes)
|
||||
if !ok {
|
||||
ctx.Warningf("tmpfs.FilesystemType.GetFilesystem: Pages RoundUp Overflow error: %q", ok)
|
||||
ctx.Warningf("tmpfs.FilesystemType.GetFilesystem: Pages RoundUp Overflow error: %v", ok)
|
||||
return nil, nil, linuxerr.EINVAL
|
||||
}
|
||||
}
|
||||
|
||||
@@ -513,13 +513,13 @@ func loadParsedELF(ctx context.Context, m *mm.MemoryManager, fd *vfs.FileDescrip
|
||||
|
||||
start, ok = start.AddLength(uint64(offset))
|
||||
if !ok {
|
||||
ctx.Infof(fmt.Sprintf("Start %#x + offset %#x overflows?", start, offset))
|
||||
ctx.Infof("Start %#x + offset %#x overflows?", start, offset)
|
||||
return loadedELF{}, linuxerr.EINVAL
|
||||
}
|
||||
|
||||
end, ok = end.AddLength(uint64(offset))
|
||||
if !ok {
|
||||
ctx.Infof(fmt.Sprintf("End %#x + offset %#x overflows?", end, offset))
|
||||
ctx.Infof("End %#x + offset %#x overflows?", end, offset)
|
||||
return loadedELF{}, linuxerr.EINVAL
|
||||
}
|
||||
|
||||
|
||||
@@ -338,5 +338,5 @@ func stubInit() {
|
||||
// Set the end.
|
||||
stubEnd = stubStart + mapLen + uintptr(gap)
|
||||
log.Debugf("stubStart %x stubSysmsgStart %x stubSysmsgStack %x, stubContextQueue %x, stubThreadContextRegion %x, mapLen %x", stubStart, stubSysmsgStart, stubSysmsgStack, stubContextQueueRegion, stubContextRegion, mapLen)
|
||||
log.Debugf(archState.String())
|
||||
log.Debugf("%s", archState.String())
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ func (s *subprocess) alive() bool {
|
||||
// The process is dead, let's collect its zombie.
|
||||
wstatus := unix.WaitStatus(0)
|
||||
pid, err := unix.Wait4(int(s.syscallThread.thread.tid), &wstatus, unix.WNOHANG, nil)
|
||||
log.Warningf("the subprocess %d exited (status: %s, err %s)", pid, wstatus, err)
|
||||
log.Warningf("the subprocess %d exited (status: %d, err %s)", pid, wstatus, err)
|
||||
s.dead.Store(true)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ func (s *CommonServer) run() {
|
||||
s.cond.L.Unlock()
|
||||
|
||||
if err := s.handshake(client); err != nil {
|
||||
log.Warningf(err.Error())
|
||||
log.Warningf("%v", err)
|
||||
s.closeClient(client)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ func (e *SCMConnectedEndpoint) beforeSave() {
|
||||
e.closeRecvLocked()
|
||||
e.closeSendLocked()
|
||||
if err := unix.Close(e.fd); err != nil {
|
||||
log.Warningf("Failed to close host fd %d: %v", err)
|
||||
log.Warningf("Failed to close host fd %d: %v", e.fd, err)
|
||||
}
|
||||
e.destroyLocked()
|
||||
}
|
||||
@@ -453,7 +453,7 @@ func (e *SCMConnectedEndpoint) Release(ctx context.Context) {
|
||||
|
||||
fdnotifier.RemoveFD(int32(e.fd))
|
||||
if err := unix.Close(e.fd); err != nil {
|
||||
log.Warningf("Failed to close host fd %d: %v", err)
|
||||
log.Warningf("Failed to close host fd %d: %v", e.fd, err)
|
||||
}
|
||||
e.destroyLocked()
|
||||
})
|
||||
|
||||
@@ -355,7 +355,7 @@ func (w *Watchdog) doAction(action Action, forceStack bool, stuckTasks map[int64
|
||||
// stack dump was generated.
|
||||
if !forceStack && time.Since(w.lastStackDump) < stackDumpSameTaskPeriod {
|
||||
msg.WriteString("\n...[stack dump skipped]...")
|
||||
log.Warningf(msg.String())
|
||||
log.Warningf("%s", msg.String())
|
||||
return
|
||||
}
|
||||
log.TracebackAll(msg.String())
|
||||
|
||||
@@ -1112,7 +1112,7 @@ func (l *Loader) run() error {
|
||||
}
|
||||
log.Infof("Received external signal %d, mode: %s", sig, deliveryMode)
|
||||
if err := l.signal(l.sandboxID, 0, int32(sig), deliveryMode); err != nil {
|
||||
log.Warningf("error sending signal %s to container %q: %s", sig, l.sandboxID, err)
|
||||
log.Warningf("error sending signal %d to container %q: %s", sig, l.sandboxID, err)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
+1
-1
@@ -388,7 +388,7 @@ func (b *bufferedEmitter) drain(emitter log.Emitter) {
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
for _, l := range b.buffer {
|
||||
emitter.Emit(l.depth, l.level, l.timestamp, l.message)
|
||||
emitter.Emit(l.depth, l.level, l.timestamp, "%s", l.message)
|
||||
}
|
||||
b.buffer = nil
|
||||
}
|
||||
|
||||
+1
-1
@@ -444,7 +444,7 @@ func makeFile(dest, content string, spec *specs.Spec) (string, error) {
|
||||
}
|
||||
if _, err := tmpFile.WriteString(content); err != nil {
|
||||
if err := os.Remove(tmpFile.Name()); err != nil {
|
||||
log.Warningf("Failed to remove %q: %v", tmpFile, err)
|
||||
log.Warningf("Failed to remove %q: %v", tmpFile.Name(), err)
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -523,7 +523,7 @@ func (fd *controlFDLisa) Open(flags uint32) (*lisafs.OpenFD, int, error) {
|
||||
case unix.S_IFSOCK:
|
||||
if !server.config.HostUDS.AllowOpen() {
|
||||
logRejectedUdsOpenOnce.Do(func() {
|
||||
log.Warningf("Rejecting attempt to open unix domain socket from host filesystem. If you want to allow this, set flag --host-uds=open", fd.ControlFD.Node().FilePath())
|
||||
log.Warningf("Rejecting attempt to open unix domain socket from host filesystem: %q. If you want to allow this, set flag --host-uds=open", fd.ControlFD.Node().FilePath())
|
||||
})
|
||||
return nil, -1, unix.EPERM
|
||||
}
|
||||
|
||||
@@ -893,7 +893,7 @@ func (s *Server) Run(ctx context.Context) error {
|
||||
m.rootDir = conf.RootDir
|
||||
if strings.Contains(conf.MetricServer, "%RUNTIME_ROOT%") {
|
||||
newAddr := strings.ReplaceAll(conf.MetricServer, "%RUNTIME_ROOT%", m.rootDir)
|
||||
log.Infof("Metric server address replaced %RUNTIME_ROOT%: %q -> %q", conf.MetricServer, newAddr)
|
||||
log.Infof("Metric server address replaced %%RUNTIME_ROOT%%: %q -> %q", conf.MetricServer, newAddr)
|
||||
conf.MetricServer = newAddr
|
||||
}
|
||||
m.address = conf.MetricServer
|
||||
|
||||
@@ -172,7 +172,7 @@ func (rc *retryableClient) Do(ctx context.Context, fn KubernetesReq) error {
|
||||
logger.Infof("Retryable operation [%s] @ %s failed on attempt %d (retryable error: %v); will retry again...", operationID, time.Now().Format(time.TimeOnly), numAttempt, err)
|
||||
lastErr = err
|
||||
}
|
||||
log.Infof("Retryable operation [%s] @ %s failed after %d attempts with retryable error (%v) but context was cancelled (%v); bailing out.", operationID, time.Now().Format(time.TimeOnly), numAttempt, lastErr)
|
||||
log.Infof("Retryable operation [%s] @ %s failed after %d attempts with retryable error (%v) but context was cancelled (%v); bailing out.", operationID, time.Now().Format(time.TimeOnly), numAttempt, lastErr, ctx.Err())
|
||||
return lastErr
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ func main() {
|
||||
c.Stdout = os.Stdout
|
||||
c.Stderr = os.Stderr
|
||||
if err := c.Run(); err != nil {
|
||||
log.Warningf(err.Error())
|
||||
log.Warningf("%v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
os.Exit(0)
|
||||
|
||||
@@ -62,8 +62,8 @@ Available commands:`, os.Args[0])
|
||||
}
|
||||
|
||||
// fail prints a warning message and exits.
|
||||
func fail(msg string, values ...any) {
|
||||
log.Warningf(msg, values...)
|
||||
func fail(msg string) {
|
||||
log.Warningf("%s", msg)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ func computeSimilarityScore(a, b *profile.Profile) (float64, error) {
|
||||
sum += math.Abs(freqA - freqB)
|
||||
totalFreq += max(freqA, freqB)
|
||||
} else {
|
||||
log.Debugf("%v is in A only: %.2f%%: %v", key, freqA*100.0)
|
||||
log.Debugf("%v is in A only: %.2f%%", key, freqA*100.0)
|
||||
sum += freqA
|
||||
totalFreq += freqA
|
||||
}
|
||||
@@ -330,7 +330,7 @@ func computeSimilarityScore(a, b *profile.Profile) (float64, error) {
|
||||
continue
|
||||
}
|
||||
if _, inA := aggA.keys[key]; !inA {
|
||||
log.Debugf("%v is in B only: %.2f%%: %v", key, freqB*100.0)
|
||||
log.Debugf("%v is in B only: %.2f%%", key, freqB*100.0)
|
||||
sum += freqB
|
||||
totalFreq += freqB
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user