Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

tiennou
Copy link
Contributor

@tiennou tiennou commented Feb 6, 2018

This is extracted from my WIP shallow/smart-transport branch (a.k.a. shallow clones).

I was very confused by the "error handling" around that function, so hopefully this makes it clearer.

Copy link
Member

@pks-t pks-t left a comment

Choose a reason for hiding this comment

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

This is definitly much more readable, so I'm very happy with your change overall. Thanks! Just some comments to make it even more readable, even though your changes already go most of the way

if (out != NULL)
*out = pkt;
else
git__free(pkt);

return pkt_type;
return error;
Copy link
Member

Choose a reason for hiding this comment

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

👍 This is our preferred style and definitly easier to handle than the previous interface

@@ -209,11 +209,11 @@ int git_smart__detect_caps(git_pkt_ref *pkt, transport_smart_caps *caps, git_vec
return 0;
}

static int recv_pkt(git_pkt **out, gitno_buffer *buf)
static int recv_pkt(git_pkt **out, git_pkt_type *pkt_type, gitno_buffer *buf)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe name it out_type instead? Just to make the parameter's intention a bit more clear

if (pkt_type == GIT_PKT_ACK) {
error = recv_pkt(NULL, &pkt_type, buf);
if (error < 0) {
goto on_error;
Copy link
Member

Choose a reason for hiding this comment

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

I'd propose to make it if ((error = recv_pkt(NULL, &pkt_type, buf)) < 0) goto on_error;. This would further disentangle handling of errors and the packet type.

if (pkt_type < 0) {
return pkt_type;
if (error < 0) {
return error;
Copy link
Member

Choose a reason for hiding this comment

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

Same here

@tiennou
Copy link
Contributor Author

tiennou commented Feb 26, 2018

Rebased against master, and fixed review comments. I stumbled on a (small) memory leak when checking uses of recv_pkt, so that's also fixed.

Copy link
Member

@pks-t pks-t left a comment

Choose a reason for hiding this comment

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

There's some places where you're accidentally using spaces instead of tabs. Otherwise it looks fine, I think

goto on_error;
} else if (pkt_type == GIT_PKT_ACK) {

if (pkt_type == GIT_PKT_ACK) {
Copy link
Member

Choose a reason for hiding this comment

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

You're using spaces instead of tabs here

return error;
} else if (pkt_type != GIT_PKT_ACK && pkt_type != GIT_PKT_NAK) {

if (pkt_type != GIT_PKT_ACK && pkt_type != GIT_PKT_NAK) {
Copy link
Member

Choose a reason for hiding this comment

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

And here as well, spaces instead of tab

if (git_vector_insert(&t->common, pkt) < 0) {
git__free(pkt);
return -1;
}
Copy link
Member

Choose a reason for hiding this comment

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

And here ;)

@tiennou tiennou force-pushed the fix/pkt-type-enum branch from eb2d9b9 to a2124a2 Compare April 11, 2018 19:04
@tiennou tiennou force-pushed the fix/pkt-type-enum branch from a2124a2 to 13a7727 Compare April 11, 2018 19:14
@tiennou
Copy link
Contributor Author

tiennou commented Apr 11, 2018

Fixup-ed spaces into tabs !

@ethomson
Copy link
Member

I like this cleanup, thanks for doing it (and thanks for your patience in getting it merged).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants