[bled] improve error reporting

* Also make the use of a FIXED drive more noticeable in the log
This commit is contained in:
Pete Batard 2017-01-11 01:12:00 +00:00
parent 8aeaa4d645
commit e62ab37e38
6 changed files with 21 additions and 21 deletions

View file

@ -28,7 +28,7 @@ jmp_buf bb_error_jmp;
static long long int unpack_none(transformer_state_t *xstate) static long long int unpack_none(transformer_state_t *xstate)
{ {
bb_printf("This compression type is not supported"); bb_error_msg("This compression type is not supported");
return -1; return -1;
} }
@ -60,18 +60,18 @@ int64_t bled_uncompress(const char* src, const char* dst, int type)
xstate.src_fd = _openU(src, _O_RDONLY | _O_BINARY, 0); xstate.src_fd = _openU(src, _O_RDONLY | _O_BINARY, 0);
if (xstate.src_fd < 0) { if (xstate.src_fd < 0) {
bb_printf("Could not open '%s' (errno: %d)", src, errno); bb_error_msg("Could not open '%s' (errno: %d)", src, errno);
goto err; goto err;
} }
xstate.dst_fd = _openU(dst, _O_WRONLY | _O_CREAT | _O_TRUNC | _O_BINARY, _S_IREAD | _S_IWRITE); xstate.dst_fd = _openU(dst, _O_WRONLY | _O_CREAT | _O_TRUNC | _O_BINARY, _S_IREAD | _S_IWRITE);
if (xstate.dst_fd < 0) { if (xstate.dst_fd < 0) {
bb_printf("Could not open '%s' (errno: %d)", dst, errno); bb_error_msg("Could not open '%s' (errno: %d)", dst, errno);
goto err; goto err;
} }
if ((type < 0) || (type >= BLED_COMPRESSION_MAX)) { if ((type < 0) || (type >= BLED_COMPRESSION_MAX)) {
bb_printf("unsupported compression format"); bb_error_msg("Unsupported compression format");
goto err; goto err;
} }
@ -106,18 +106,18 @@ int64_t bled_uncompress_with_handles(HANDLE hSrc, HANDLE hDst, int type)
xstate.src_fd = _open_osfhandle((intptr_t)hSrc, _O_RDONLY); xstate.src_fd = _open_osfhandle((intptr_t)hSrc, _O_RDONLY);
if (xstate.src_fd < 0) { if (xstate.src_fd < 0) {
bb_printf("Could not get source descriptor (errno: %d)", errno); bb_error_msg("Could not get source descriptor (errno: %d)", errno);
return -1; return -1;
} }
xstate.dst_fd = _open_osfhandle((intptr_t)hDst, 0); xstate.dst_fd = _open_osfhandle((intptr_t)hDst, 0);
if (xstate.dst_fd < 0) { if (xstate.dst_fd < 0) {
bb_printf("Could not get target descriptor (errno: %d)", errno); bb_error_msg("Could not get target descriptor (errno: %d)", errno);
return -1; return -1;
} }
if ((type < 0) || (type >= BLED_COMPRESSION_MAX)) { if ((type < 0) || (type >= BLED_COMPRESSION_MAX)) {
bb_printf("unsupported compression format"); bb_error_msg("Unsupported compression format");
return -1; return -1;
} }
@ -143,7 +143,7 @@ int64_t bled_uncompress_to_buffer(const char* src, char* buf, size_t size, int t
xstate.src_fd = _openU(src, _O_RDONLY | _O_BINARY, 0); xstate.src_fd = _openU(src, _O_RDONLY | _O_BINARY, 0);
if (xstate.src_fd < 0) { if (xstate.src_fd < 0) {
bb_printf("Could not open '%s' (errno: %d)", src, errno); bb_error_msg("Could not open '%s' (errno: %d)", src, errno);
goto err; goto err;
} }
@ -152,7 +152,7 @@ int64_t bled_uncompress_to_buffer(const char* src, char* buf, size_t size, int t
xstate.mem_output_size_max = size; xstate.mem_output_size_max = size;
if ((type < 0) || (type >= BLED_COMPRESSION_MAX)) { if ((type < 0) || (type >= BLED_COMPRESSION_MAX)) {
bb_printf("unsupported compression format"); bb_error_msg("Unsupported compression format");
goto err; goto err;
} }

View file

@ -309,7 +309,7 @@ IF_DESKTOP(long long) int FAST_FUNC unpack_zip_stream(transformer_state_t *xstat
/* Read filename */ /* Read filename */
filename = xzalloc(zip_header.formatted.filename_len + 1); filename = xzalloc(zip_header.formatted.filename_len + 1);
safe_read(xstate->src_fd, filename, zip_header.formatted.filename_len); safe_read(xstate->src_fd, filename, zip_header.formatted.filename_len);
bb_printf("processing archive file '%s'", filename); bb_printf("Processing archive file '%s'", filename);
free(filename); free(filename);
/* Skip extra header bytes */ /* Skip extra header bytes */

View file

@ -136,9 +136,9 @@ extern unsigned long* bled_cancel_request;
#define xfunc_die() longjmp(bb_error_jmp, 1) #define xfunc_die() longjmp(bb_error_jmp, 1)
#define bb_printf(...) do { if (bled_printf != NULL) bled_printf(__VA_ARGS__); \ #define bb_printf(...) do { if (bled_printf != NULL) bled_printf(__VA_ARGS__); \
else { printf(__VA_ARGS__); putchar('\n'); } } while(0) else { printf(__VA_ARGS__); putchar('\n'); } } while(0)
#define bb_error_msg bb_printf #define bb_error_msg(...) bb_printf("Error: " __VA_ARGS__)
#define bb_error_msg_and_die(...) do {bb_printf(__VA_ARGS__); xfunc_die();} while(0) #define bb_error_msg_and_die(...) do {bb_error_msg(__VA_ARGS__); xfunc_die();} while(0)
#define bb_error_msg_and_err(...) do {bb_printf(__VA_ARGS__); goto err;} while(0) #define bb_error_msg_and_err(...) do {bb_error_msg(__VA_ARGS__); goto err;} while(0)
#define bb_perror_msg bb_error_msg #define bb_perror_msg bb_error_msg
#define bb_perror_msg_and_die bb_error_msg_and_die #define bb_perror_msg_and_die bb_error_msg_and_die
#define bb_putchar putchar #define bb_putchar putchar
@ -153,7 +153,7 @@ static inline void *xrealloc(void *ptr, size_t size) {
#define bb_msg_read_error "read error" #define bb_msg_read_error "read error"
#define bb_msg_write_error "write error" #define bb_msg_write_error "write error"
#define bb_mode_string(mode) "[not implemented]" #define bb_mode_string(mode) "[not implemented]"
#define bb_copyfd_exact_size(fd1, fd2, size) bb_printf("not implemented") #define bb_copyfd_exact_size(fd1, fd2, size) bb_error_msg("Not implemented")
#define bb_make_directory(path, mode, flags) SHCreateDirectoryExU(NULL, path, NULL) #define bb_make_directory(path, mode, flags) SHCreateDirectoryExU(NULL, path, NULL)
static inline int link(const char *oldpath, const char *newpath) {errno = ENOSYS; return -1;} static inline int link(const char *oldpath, const char *newpath) {errno = ENOSYS; return -1;}

View file

@ -44,7 +44,7 @@ ssize_t FAST_FUNC transformer_write(transformer_state_t *xstate, const void *buf
} else { } else {
nwrote = full_write(xstate->dst_fd, buf, (unsigned)bufsize); nwrote = full_write(xstate->dst_fd, buf, (unsigned)bufsize);
if (nwrote != (ssize_t)bufsize) { if (nwrote != (ssize_t)bufsize) {
bb_perror_msg("write"); bb_perror_msg("write error - %d bytes written but %d expected", (int)nwrote, (int)bufsize);
nwrote = -1; nwrote = -1;
goto ret; goto ret;
} }

View file

@ -700,7 +700,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
SelectedDrive.SectorsPerTrack = DiskGeometry->Geometry.SectorsPerTrack; SelectedDrive.SectorsPerTrack = DiskGeometry->Geometry.SectorsPerTrack;
SelectedDrive.MediaType = DiskGeometry->Geometry.MediaType; SelectedDrive.MediaType = DiskGeometry->Geometry.MediaType;
suprintf("Disk type: %s, Sector Size: %d bytes\n", (SelectedDrive.MediaType == FixedMedia)?"Fixed":"Removable", suprintf("Disk type: %s, Sector Size: %d bytes\n", (SelectedDrive.MediaType == FixedMedia)?"FIXED":"Removable",
SelectedDrive.SectorSize); SelectedDrive.SectorSize);
suprintf("Cylinders: %" PRIi64 ", TracksPerCylinder: %d, SectorsPerTrack: %d\n", suprintf("Cylinders: %" PRIi64 ", TracksPerCylinder: %d, SectorsPerTrack: %d\n",
DiskGeometry->Geometry.Cylinders, DiskGeometry->Geometry.TracksPerCylinder, DiskGeometry->Geometry.SectorsPerTrack); DiskGeometry->Geometry.Cylinders, DiskGeometry->Geometry.TracksPerCylinder, DiskGeometry->Geometry.SectorsPerTrack);

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 242, 376 IDD_DIALOG DIALOGEX 12, 12, 242, 376
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 2.12.1017" CAPTION "Rufus 2.12.1018"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0 FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@ -334,8 +334,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,12,1017,0 FILEVERSION 2,12,1018,0
PRODUCTVERSION 2,12,1017,0 PRODUCTVERSION 2,12,1018,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -352,13 +352,13 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.12.1017" VALUE "FileVersion", "2.12.1018"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe" VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "2.12.1017" VALUE "ProductVersion", "2.12.1018"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"