Skip to content

Commit

Permalink
remove ref global varible g_verbose in bmap.cpp
Browse files Browse the repository at this point in the history
g_verbose should be used only at uuu.cpp. Libuuu internal use debug
level to decide which information should be return to caller.

Signed-off-by: Frank Li <frank.li@nxp.com>
  • Loading branch information
nxpfrankli committed Aug 12, 2024
1 parent c031b2a commit 09fe178
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
4 changes: 1 addition & 3 deletions libuuu/bmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include "libcomm.h"
#include "libuuu.h"

extern int g_verbose;

bmap_mode g_bmap_mode = bmap_mode::Default;

bmap_mode uuu_get_bmap_mode()
Expand Down Expand Up @@ -160,7 +158,7 @@ bool load_bmap(const std::string& filename, bmap_t& bmap)
return -1;
}

if (g_verbose) {
if (get_libuuu_debug_level() > LIBUUU_NORMAL) {
auto info = std::string("\nUsing block map:") +
"\n ImageSize: " + std::to_string(bmap.image_size()) +
"\n BlockSize: " + std::to_string(bmap.block_size()) +
Expand Down
5 changes: 5 additions & 0 deletions libuuu/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ int get_libusb_debug_level() noexcept
return g_debug_level & 0xFFFF;
}

int get_libuuu_debug_level() noexcept
{
return g_debug_level & 0xFFFF0000;
}

void uuu_set_debug_level(uint32_t mask)
{
g_debug_level = mask;
Expand Down
1 change: 1 addition & 0 deletions libuuu/libcomm.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void call_notify(struct uuu_notify nf);
#define dbg printf

int get_libusb_debug_level() noexcept;
int get_libuuu_debug_level() noexcept;

class string_ex : public std::string
{
Expand Down
6 changes: 6 additions & 0 deletions libuuu/libuuu.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ int uuu_set_wait_timeout(int timeout_in_seconds);
int uuu_set_wait_next_timeout(int timeout_in_seconds);
/*Set usb device polling period */
void uuu_set_poll_period(int period_in_milliseconds);

enum LIBUUU_DEBUG_LEVEL
{
LIBUUU_NORMAL = 0,
LIBUUU_DETAIL = 0x8 << 16,
};
/*
* bit 0:15 for libusb
* bit 16:31 for uuu
Expand Down
3 changes: 2 additions & 1 deletion uuu/uuu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,11 +960,12 @@ int main(int argc, char **argv)
else if (s == "-v")
{
g_verbose = 1;
uuu_set_debug_level(LIBUUU_DETAIL);
}
else if (s == "-V")
{
g_verbose = 1;
uuu_set_debug_level(2);
uuu_set_debug_level(LIBUUU_DETAIL | 2);
}else if (s == "-dry")
{
dryrun = 1;
Expand Down

0 comments on commit 09fe178

Please sign in to comment.