mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Implement error on pointers
This improves type-assertion safety. PiperOrigin-RevId: 353931228
This commit is contained in:
committed by
gVisor bot
parent
a90661654d
commit
ce39f82985
@@ -34,7 +34,9 @@ func (p *pipeOperations) beforeSave() {
|
||||
} else if p.flags.Write {
|
||||
file, err := p.opener.NonBlockingOpen(context.Background(), fs.PermMask{Write: true})
|
||||
if err != nil {
|
||||
panic(fs.ErrSaveRejection{fmt.Errorf("write-only pipe end cannot be re-opened as %v: %v", p, err)})
|
||||
panic(&fs.ErrSaveRejection{
|
||||
Err: fmt.Errorf("write-only pipe end cannot be re-opened as %#v: %w", p, err),
|
||||
})
|
||||
}
|
||||
file.Close()
|
||||
}
|
||||
|
||||
+1
-1
@@ -144,7 +144,7 @@ type ErrSaveRejection struct {
|
||||
}
|
||||
|
||||
// Error returns a sensible description of the save rejection error.
|
||||
func (e ErrSaveRejection) Error() string {
|
||||
func (e *ErrSaveRejection) Error() string {
|
||||
return "save rejected due to unsupported file system state: " + e.Err.Error()
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,9 @@ func (i *inodeFileState) beforeSave() {
|
||||
if i.sattr.Type == fs.RegularFile {
|
||||
uattr, err := i.unstableAttr(&dummyClockContext{context.Background()})
|
||||
if err != nil {
|
||||
panic(fs.ErrSaveRejection{fmt.Errorf("failed to get unstable atttribute of %s: %v", i.s.inodeMappings[i.sattr.InodeID], err)})
|
||||
panic(&fs.ErrSaveRejection{
|
||||
Err: fmt.Errorf("failed to get unstable atttribute of %s: %w", i.s.inodeMappings[i.sattr.InodeID], err),
|
||||
})
|
||||
}
|
||||
i.savedUAttr = &uattr
|
||||
}
|
||||
|
||||
@@ -593,8 +593,8 @@ func (k *Kernel) flushWritesToFiles(ctx context.Context) error {
|
||||
// Wrap this error in ErrSaveRejection so that it will trigger a save
|
||||
// error, rather than a panic. This also allows us to distinguish Fsync
|
||||
// errors from state file errors in state.Save.
|
||||
return fs.ErrSaveRejection{
|
||||
Err: fmt.Errorf("%q was not sufficiently synced: %v", name, err),
|
||||
return &fs.ErrSaveRejection{
|
||||
Err: fmt.Errorf("%q was not sufficiently synced: %w", name, err),
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
+1
-1
@@ -195,7 +195,7 @@ type ErrSaveRejection struct {
|
||||
}
|
||||
|
||||
// Error returns a sensible description of the save rejection error.
|
||||
func (e ErrSaveRejection) Error() string {
|
||||
func (e *ErrSaveRejection) Error() string {
|
||||
return "save rejected due to unsupported networking state: " + e.Err.Error()
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,9 @@ func (e *endpoint) beforeSave() {
|
||||
case epState.connected() || epState.handshake():
|
||||
if !e.route.HasSaveRestoreCapability() {
|
||||
if !e.route.HasDisconncetOkCapability() {
|
||||
panic(tcpip.ErrSaveRejection{fmt.Errorf("endpoint cannot be saved in connected state: local %v:%d, remote %v:%d", e.ID.LocalAddress, e.ID.LocalPort, e.ID.RemoteAddress, e.ID.RemotePort)})
|
||||
panic(&tcpip.ErrSaveRejection{
|
||||
Err: fmt.Errorf("endpoint cannot be saved in connected state: local %s:%d, remote %s:%d", e.ID.LocalAddress, e.ID.LocalPort, e.ID.RemoteAddress, e.ID.RemotePort),
|
||||
})
|
||||
}
|
||||
e.resetConnectionLocked(tcpip.ErrConnectionAborted)
|
||||
e.mu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user