-
Notifications
You must be signed in to change notification settings - Fork 826
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
Cleaning conditional directives that break statements. #645
base: bfgminer
Are you sure you want to change the base?
Changes from all commits
a508bdb
e5f7349
edacbd2
4e8ac63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,11 +83,13 @@ int minergate_open(const char * const devpath) | |
struct sockaddr_un sa = { | ||
.sun_family = AF_UNIX, | ||
}; | ||
bool test; | ||
#ifdef UNIX_PATH_MAX | ||
if (devpath_len >= UNIX_PATH_MAX) | ||
test devpath_len >= UNIX_PATH_MAX; | ||
#else | ||
if (devpath_len >= sizeof(sa.sun_path)) | ||
test = devpath_len >= sizeof(sa.sun_path); | ||
#endif | ||
if (test) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it be better to do: #ifndef UNIX_PATH_MAX
static const size_t UNIX_PATH_MAX = sizeof(sa.sun_path);
#endif |
||
return -1; | ||
const int fd = socket(PF_UNIX, SOCK_STREAM, 0); | ||
strcpy(sa.sun_path, devpath); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -308,6 +308,7 @@ static int keep_sockalive(SOCKETTYPE fd) | |
const int tcp_keepidle = 45; | ||
const int tcp_keepintvl = 30; | ||
int ret = 0; | ||
bool unlikely_test; | ||
|
||
if (unlikely(setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (const char *)&tcp_one, sizeof(tcp_one)))) | ||
ret = 1; | ||
|
@@ -324,10 +325,11 @@ static int keep_sockalive(SOCKETTYPE fd) | |
|
||
if (!opt_delaynet) | ||
#ifndef __linux | ||
if (unlikely(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const void *)&tcp_one, sizeof(tcp_one)))) | ||
unlikely_test = unlikely(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const void *)&tcp_one, sizeof(tcp_one))); | ||
#else /* __linux */ | ||
if (unlikely(setsockopt(fd, SOL_TCP, TCP_NODELAY, (const void *)&tcp_one, sizeof(tcp_one)))) | ||
unlikely_test = unlikely(setsockopt(fd, SOL_TCP, TCP_NODELAY, (const void *)&tcp_one, sizeof(tcp_one))); | ||
#endif /* __linux */ | ||
if (unlikely_test) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't the unlikely() need to be in the conditional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, this is broken. Notice the conditional on opt_delaynet before the #ifndef You'll need to add braces when breaking up the one-liner. |
||
ret = 1; | ||
|
||
#ifdef __linux | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure this is wrong?