Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raspberry usb fix #92

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions libuuu/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@
#include <sys/stat.h>
#include <thread>

#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>

static CmdMap g_cmd_map;
static CmdObjCreateMap g_cmd_create_map;
Expand Down Expand Up @@ -237,21 +238,17 @@ int get_string_in_square_brackets(string &cmd, string &context)
uint32_t str_to_uint(string &str)
{
uint32_t val = 0;
const char * start = str.substr(0).c_str();
char * endPtr = const_cast<char*>(start);
std::stringstream ss;
if (str.size() > 2 &&
str.substr(0, 2).compare("0x") == 0)
{
val = strtoul(start+2, &endPtr, 16);
ss << std::hex << str.substr(2);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's problem do you try to fix? the function should be the same

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't know why but the old code fail to convert on x86_64 latest ubuntu.... and well c++ conversion function are more robust than the strtoul legacy

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It pass ubuntu 18.08 at auto build system.

else
{
val = strtoul(start, &endPtr, 10);
}
if (start == endPtr)
{
throw ("Trying to convert non numeric value to int");
ss << std::dec << str;
}
ss >> val;
return val;
}

Expand Down