-
Notifications
You must be signed in to change notification settings - Fork 79
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
Sparse image format + Some fixes #5
base: master
Are you sure you want to change the base?
Conversation
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.
Some very initial comments.. i haven't reviewed the bulk of the series yet..
please make sure you have signed-off line, and better commit logs. you also need to split patches into individual logical chunks when appropriate.
@@ -46,11 +46,11 @@ | |||
#include <termios.h> | |||
#include <time.h> | |||
#include <unistd.h> | |||
#include <libxml/parser.h> | |||
#include <libxml/tree.h> | |||
|
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.
this is not needed (and does not correspond to what you have in the commit log).
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.
libxml/parser.h is unneeded and the libxml/tree.h is included in util.h.
util.h is new header which declares xml parsing wrapper functions, which were previously declared in qdl.h. I don't see by what reason qdl I/O API should be mixed with XML parsing API.
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.
I have updated patch with commit message with all reasons.
firehose.c
Outdated
@@ -153,7 +153,8 @@ static int firehose_read(struct qdl_device *qdl, int wait, int (*response_parser | |||
for (node = nodes; node; node = node->next) { | |||
if (xmlStrcmp(node->name, (xmlChar*)"log") == 0) { | |||
firehose_response_log(node); | |||
} else if (xmlStrcmp(node->name, (xmlChar*)"response") == 0) { | |||
} | |||
else if (xmlStrcmp(node->name, (xmlChar*)"response") == 0) { |
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.
please do not change code style. or if you do , then you need to do it consistently and in a separate patch anyways.
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.
I will push patch with reverted code style.
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.
I have updated patch with reverted code style.
@@ -102,7 +101,7 @@ int patch_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl, s | |||
int ret; | |||
|
|||
for (patch = patches; patch; patch = patch->next) { | |||
if (strcmp(patch->filename, "DISK")) | |||
if (xmlStrcmp(patch->filename, (const xmlChar *)"DISK")) |
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.
can you justify why/how xmlStrcmp() is better than strcmp()? it would have been a good idea to provide that info in the commit message, btw.
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.
It's better because XML API returns xmlChar which is unsigned char. As we use libxml2 there is no reason to use normal strcmp.
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.
I forgot to mention that the standard does not specify if plain char is signed or unsigned.
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.
I have updated patch with commit message with all reasons.
@@ -156,11 +155,11 @@ int program_execute(struct qdl_device *qdl, int (*apply)(struct qdl_device *qdl, | |||
int program_find_bootable_partition(void) | |||
{ | |||
struct program *program; | |||
const char *label; | |||
char *label; |
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.
why?
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.
Why we should use const, when pointer holds dynamically allocated data and dynamically assigned value?
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.
I have updated patch with commit message with all reasons.
@@ -0,0 +1,10 @@ | |||
#ifndef __UTIL_H__ |
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.
this change does not relate to this commit subject
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.
I will update commit message to be more informational.
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.
I have updated patch with commit message with all reasons.
@@ -94,7 +94,7 @@ unsigned attr_as_unsigned(xmlNode *node, const char *attr, int *errors) | |||
return (unsigned int) strtoul((char*)value, NULL, 10); | |||
} | |||
|
|||
const char *attr_as_string(xmlNode *node, const char *attr, int *errors) | |||
xmlChar *attr_as_string(xmlNode *node, const char *attr, int *errors) |
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.
this function converts a xml attribute into a string. i don't understand why you want to use xmlChar, since the purpose is to extract information from xml.
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.
It's better because XML API returns xmlChar which is unsigned char. As we use libxml2 there is no reason to use other types. With this change things becomes more clear for use.
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.
I have updated patch with commit message with all reasons.
firehose.c
Outdated
@@ -103,6 +103,8 @@ static void firehose_response_log(xmlNode *node) | |||
|
|||
value = xmlGetProp(node, (xmlChar*)"value"); | |||
printf("LOG: %s\n", value); | |||
|
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.
un-needed empty line
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.
Will be removed.
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.
I have updated patch with removed extra line.
firehose.c
Outdated
|
||
value = xmlGetProp(node, (xmlChar*)"value"); | ||
return !!xmlStrcmp(value, (xmlChar*)"ACK"); | ||
ret = !!xmlStrcmp(value, (xmlChar*)"ACK"); | ||
|
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.
ditto.
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.
I have updated patch with removed extra line.
@@ -215,9 +221,14 @@ static int firehose_configure_response_parser(xmlNode *node) | |||
size_t max_size; | |||
|
|||
value = xmlGetProp(node, (xmlChar*)"value"); | |||
if (!value) | |||
return -EINVAL; |
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.
I am not sure that EINVAL will be interpretated correctly by callers here.
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.
Before my patch it returns also -EINVAL.
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.
right. sorry i missed that ;-)
sahara.c
Outdated
@@ -196,8 +196,8 @@ static int sahara_done(struct qdl_device *qdl, struct sahara_pkt *pkt) | |||
|
|||
int sahara_run(struct qdl_device *qdl, char *prog_mbn) | |||
{ | |||
struct sahara_pkt *pkt; | |||
char buf[4096]; | |||
struct sahara_pkt *pkt = NULL; |
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.
these 2 lines are not related to commit log.
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.
I have updated patch with removed extra initialization.
190ccba
to
68f2a11
Compare
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.
Some comment inline.
In particular I think it would be nice if you could split this into "freeing of resources", "style changes" and "initialize xml parser".
Thanks,
Bjorn
program.c
Outdated
if (programes_last) | ||
free(programes_last); | ||
|
||
programes_last = program; |
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.
Use a second variable to track the "next" element as you free up the current "program".
for (program = programs; program; program = next) {
next = program->next;
free(program);
}
program.c
Outdated
|
||
for (program = programes; program; program = program->next) { | ||
if (program->filename) | ||
xmlFree(program->filename); |
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.
Analog to standard free() it's valid to pass NULL to this function, so remove the extra conditionals before each one of these.
patch.c
Outdated
patches_last = NULL; | ||
|
||
for (patch = patches; patch; patch = patch->next) { | ||
if (patch->filename) |
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.
Same comments as for program_unload() below (just read your patch backwards).
@@ -305,3 +305,22 @@ int ufs_provisioning_execute(struct qdl_device *qdl, | |||
} | |||
return apply_ufs_epilogue(qdl, ufs_epilogue_p, true); | |||
} | |||
|
|||
void ufs_unload(void) |
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.
Same as program_unload().
@@ -464,6 +477,8 @@ int main(int argc, char **argv) | |||
|
|||
prog_mbn = argv[optind++]; | |||
|
|||
xmlInitParser(); |
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.
This doesn't seem to fall into the same category as the other fixes in this patch; you have freeing of memory, some style changes and this.
I think it would be nice if this was 3 different patches.
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.
I was under the impression that going towards standard types would be a better choice, but after reading your patch I'm happy with the result. Let's use xmlChar in all places that deals with xml data.
But you have listed three different things you changed in your commit message, that's a good reason to split this into three distinct patches. Please do so.
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.
LGTM
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.
I presume you mean that you removed some parts of the API that we don't need.
Otherwise it would be good to track this delta by first adding a verbatim copy of the files, then add a commit that migrates the code to what we want and finally one that adds it to the Makefile.
I tried this implementation (with valgrind) and I'm seeing this:
|
I am splitting patches, now due to latest review and will address this issue. |
This change is due to difference between code style on base source and libsparse source.
This change is due to project structure.
- output_file.c to output_stream.c - output_file.h to output_stream.h
- removed unused code - removed crc support - removed gz compression support - renamed all "file" named structures and functions to "stream" in output_stream.c
seperate header, they should not be mixed with qdl I/O API. In result there is a new util.h header.
strcmp to xmlStrcmp. Also removed const qualifiers on dynamically assigned variables.
strcmp to xmlStrcmp and free to xmlFree. Also removed const qualifiers on dynamically assigned variables.
to the library
68f2a11
to
22234e6
Compare
Hi Bjorn, Regards, |
Tried it, seems to work for me now ;-) |
Thank you, for the feedback. |
@abozhinov444 Do you have a chance to rebase onto HEAD ? |
Based on original work from linux-msm#5 Signed-off-by: Christopher Obbard <[email protected]>
Is this PR getting merged? What's the status? |
No description provided.