@@ -75,22 +75,21 @@ pub type Result<T> = std::result::Result<T, Error>;
75
75
76
76
impl fmt:: Display for Error {
77
77
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
78
- let desc = match self {
78
+ write ! ( f, "Kernel Loader: " ) ?;
79
+ match self {
79
80
#[ cfg( all( feature = "bzimage" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
80
- Error :: Bzimage ( ref _e ) => "failed to load bzImage kernel image" ,
81
+ Error :: Bzimage ( ref e ) => write ! ( f , "failed to load bzImage kernel image: {e}" ) ,
81
82
#[ cfg( all( feature = "elf" , any( target_arch = "x86" , target_arch = "x86_64" ) ) ) ]
82
- Error :: Elf ( ref _e ) => "failed to load ELF kernel image" ,
83
+ Error :: Elf ( ref e ) => write ! ( f , "failed to load ELF kernel image: {e}" ) ,
83
84
#[ cfg( all( feature = "pe" , target_arch = "aarch64" ) ) ]
84
- Error :: Pe ( ref _e) => "failed to load PE kernel image" ,
85
-
86
- Error :: InvalidCommandLine => "invalid command line provided" ,
87
- Error :: CommandLineCopy => "failed writing command line to guest memory" ,
88
- Error :: CommandLineOverflow => "command line overflowed guest memory" ,
89
- Error :: InvalidKernelStartAddress => "invalid kernel start address" ,
90
- Error :: MemoryOverflow => "memory to load kernel image is not enough" ,
91
- } ;
85
+ Error :: Pe ( ref e) => write ! ( f, "failed to load PE kernel image: {e}" ) ,
92
86
93
- write ! ( f, "Kernel Loader: {}" , desc)
87
+ Error :: InvalidCommandLine => write ! ( f, "invalid command line provided" ) ,
88
+ Error :: CommandLineCopy => write ! ( f, "failed writing command line to guest memory" ) ,
89
+ Error :: CommandLineOverflow => write ! ( f, "command line overflowed guest memory" ) ,
90
+ Error :: InvalidKernelStartAddress => write ! ( f, "invalid kernel start address" ) ,
91
+ Error :: MemoryOverflow => write ! ( f, "memory to load kernel image is not enough" ) ,
92
+ }
94
93
}
95
94
}
96
95
0 commit comments