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

lib/commit: fix using uninitialized var #1216

Closed
wants to merge 2 commits into from

Conversation

jlebon
Copy link
Member

@jlebon jlebon commented Sep 26, 2017

Noticed this while reading the code. The child var hasn't been
initialized yet at the time we throw this error (and even then, it's
only conditionally initialized). To be nice, let's just always calculate
the child path and pass that along.

Also do some minor style porting to decl near use.

Split out from #1170.

Add a few comments for each of the central functions used for committing
data from a directory. Took me a bit to understand the relationship
between those functions.
Noticed this while reading the code. The `child` var hasn't been
initialized yet at the time we throw this error (and even then, it's
only conditionally initialized). To be nice, let's just always calculate
the child path and pass that along.

Also do some minor style porting to decl near use.
g_ptr_array_add (path, (char*)name);

if (modifier != NULL)
child_relpath = ptrarray_path_join (path);
g_autofree char *child_relpath = ptrarray_path_join (path);
Copy link
Member

Choose a reason for hiding this comment

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

IIRC I did this intentionally to avoid the malloc if we didn't have a commit modifier. But eh, perhaps down the line we can tweak this to use a scratch GString buffer like we do in other places.

@cgwalters
Copy link
Member

@rh-atomic-bot r+ d33828e

@rh-atomic-bot
Copy link

⌛ Testing commit d33828e with merge e44631e...

rh-atomic-bot pushed a commit that referenced this pull request Sep 26, 2017
Noticed this while reading the code. The `child` var hasn't been
initialized yet at the time we throw this error (and even then, it's
only conditionally initialized). To be nice, let's just always calculate
the child path and pass that along.

Also do some minor style porting to decl near use.

Closes: #1216
Approved by: cgwalters
@rh-atomic-bot
Copy link

☀️ Test successful - status-atomicjenkins
Approved by: cgwalters
Pushing e44631e to master...

@jlebon jlebon deleted the pr/uninit-var branch June 14, 2018 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants