-
Notifications
You must be signed in to change notification settings - Fork 286
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
lwNBDsvr: Small refactoring #506
Conversation
Please take a look at the codacy issues. Let me know when you're satisfied, then I'll pull the changes. |
a88e4b7
to
76db1d7
Compare
Ok for me, still better. I get some ATAD error sometime like :
on ata_get_devinfo but seems harmless and
|
size = nbd_send(client_socket, &new_hs, sizeof(struct nbd_new_handshake), | ||
0); | ||
if (size < sizeof(struct nbd_new_handshake)) | ||
goto error; |
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.
is it possible to get rid of all goto? Something like return ctx
, or return null
. Goto can lead to some problems in the future.
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.
If you want more description, you can define retcodes somewhere like
RET_ERROR = 0;
RET_SOFTDISCONNECT = -1;
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.
break; | ||
// see nbdkit send_newstyle_option_reply_exportnames() | ||
case NBD_OPT_LIST: | ||
|
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.
for strlen warnings, maybe just for safety:
ctx->export_name[32] = '\0';
ctx-> export_desc[64] = '\0';
we use static arrays, I dont think that we will ofill the whole string, but for safety this can be assigned
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.
@@ -397,6 +103,8 @@ int nbd_init(struct nbd_context **ctx) | |||
|
|||
while (1) { | |||
|
|||
printf("lwNBD: a new client connected.\n"); |
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.
Maybe all printf do only ifdef DEBUG ?? printf is a bit heavy function, can cause timeouts and slowdowns
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.
or use dbgprintf
instead
lwNBDsvr: Small refactoring
Pull Request checklist
Note: these are not necessarily requirements
Pull Request description