Signed-off-by: Sarah Khan <[email protected]>
PATCH 1/1 Signed-off-by: Sarah Khan <[email protected]>
This patch replaces malloc() with g_malloc() as stated to be done in bitesized task
thunk.c +1 -1
@@ -88,7 +88,7 @@ void thunk_register_struct(int id, const char *name, const argtype *types)for (i =0 ;i <2 ; i++) { offset =0 ; max_align =1 ; - se->field_offsets[i] =malloc (nb_fields *sizeof (int )); + se->field_offsets[i] =g_malloc (nb_fields *sizeof (int )); type_ptr = se->field_types;for (j =0 ;j < nb_fields; j++) { size =thunk_type_size (type_ptr, i);
--- thunk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
thunk.c +1 -1
@@ -88,7 +88,7 @@ void thunk_register_struct(int id, const char *name, const argtype *types)for (i =0 ;i <2 ; i++) { offset =0 ; max_align =1 ; - se->field_offsets[i] =malloc (nb_fields *sizeof (int )); + se->field_offsets[i] =g_malloc (nb_fields *sizeof (int )); type_ptr = se->field_types;for (j =0 ;j < nb_fields; j++) { size =thunk_type_size (type_ptr, i);
Signature · 1 line
1.9.1
Quoted 7 lines · Sarah Khan
This patch replaces
malloc()withg_malloc()as stated to be done in bitesized taskthunk.c +0
-0
thunk.c void thunk_register_struct(int id, const char *name, const argtype *types) · line 94
Quoted 8 lines
thunk.c +1
-1@@ -88,7 +88,7 @@ void thunk_register_struct(int id, const char *name, const argtype *types)for (i =0 ;i <2 ; i++) { offset =0 ; max_align =1 ; - se->field_offsets[i] =malloc (nb_fields *sizeof (int )); + se->field_offsets[i] =g_malloc (nb_fields *sizeof (int )); type_ptr = se->field_types;for (j =0 ;j < nb_fields; j++) { size =thunk_type_size (type_ptr, i);
Where is the corresponding free()? g_malloc() must be paired with g_free(), so you need to convert both places at once.
Also, your patch is missing a Signed-off-by designation; without that, we can't accept it. More hints at:
http://wiki.qemu.org/Contribute/SubmitAPatch
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/SubmittingPatches?id=f6f94e2ab1#n297
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 20 lines · Eric Blake
Quoted 7 lines · Sarah Khan
This patch replaces
malloc()withg_malloc()as stated to be done in bitesized taskthunk.c +0
-0thunk.c void thunk_register_struct(int id, const char *name, const argtype *types) · line 94
Quoted 8 lines
thunk.c +1
-1@@ -88,7 +88,7 @@ void thunk_register_struct(int id, const char *name, const argtype *types)for (i =0 ;i <2 ; i++) { offset =0 ; max_align =1 ; - se->field_offsets[i] =malloc (nb_fields *sizeof (int )); + se->field_offsets[i] =g_malloc (nb_fields *sizeof (int )); type_ptr = se->field_types;for (j =0 ;j < nb_fields; j++) { size =thunk_type_size (type_ptr, i);Where is the corresponding
free()?g_malloc()must be paired withg_free(), so you need to convert both places at once.
Quoted 2 lines
Also, your patch is missing a Signed-off-by designation; without that, we can't accept it.
Oh, I see you DID include a S-o-b, but in the subject line of the patch instead of the commit body. Which still needs work. You need a one-line summary as the subject, not your S-o-b, so the commit message should look more like:
thunk: Replace malloc with g_malloc()
This replacement was suggested as part of the bite-sized tasks.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 10 lines · Eric Blake
Oh, I see you DID include a S-o-b, but in the subject line of the patch instead of the commit body. Which still needs work. You need a one-line summary as the subject, not your S-o-b, so the commit message should look more like:
thunk: Replace malloc with
g_malloc()This replacement was suggested as part of the bite-sized tasks.
Signed-off-by Sarah Khan <[email protected]>
Oh, and I'd be remiss if I did not add:
This looks like your first contribution. Welcome to the QEMU community, and hope you enjoy it here! Keep in mind that email is a bad medium for expressing emotion, and that reviewers tend to point out flaws without looking for the good; but in reality, we are grateful when someone steps up to help with the bite-sized tasks.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Peter Maydell
Reviewed-byQuoted 19 lines · Eric Blake
Quoted 7 lines · Sarah Khan
This patch replaces
malloc()withg_malloc()as stated to be done in bitesized taskthunk.c +0
-0thunk.c void thunk_register_struct(int id, const char *name, const argtype *types) · line 94
Quoted 8 lines
thunk.c +1
-1@@ -88,7 +88,7 @@ void thunk_register_struct(int id, const char *name, const argtype *types)for (i =0 ;i <2 ; i++) { offset =0 ; max_align =1 ; - se->field_offsets[i] =malloc (nb_fields *sizeof (int )); + se->field_offsets[i] =g_malloc (nb_fields *sizeof (int )); type_ptr = se->field_types;for (j =0 ;j < nb_fields; j++) { size =thunk_type_size (type_ptr, i);Where is the corresponding
free()?g_malloc()must be paired withg_free(), so you need to convert both places at once.
There is no corresponding free(). thunk_register_struct() is called only at startup from the linux-user code in order to populate the struct_entries array; this data structure then remains live for the entire lifetime of the program and is automatically freed when QEMU exits.
This is worth mentioning in the commit message, but the code is correct I think:
thanks
-- PMM
Sarah Khan
Reviewed-by Peter MaydellOk. Will complete the required.
Thanks,
Sarah
Quoted 2 lines · Eric Blake
Quoted 1 line · Sarah Khan
This patch replaces
malloc()withg_malloc()as stated to be done in
bitesized task
Quoted 6 lines
thunk.c void thunk_register_struct(int id, const char *name,
Quoted 6 lines
thunk.c +0
-0@@ -88,7 +88,7 @@ void thunk_register_struct(int id, const char *name,
const argtype *types)
Quoted 11 lines
thunk.c void thunk_register_struct(int id, const char *name, const argtype *types) · line 94
Quoted 8 lines
thunk.c +1
-1for (i =0 ;i <2 ; i++) { offset =0 ; max_align =1 ; - se->field_offsets[i] =malloc (nb_fields *sizeof (int )); + se->field_offsets[i] =g_malloc (nb_fields *sizeof (int )); type_ptr = se->field_types;for (j =0 ;j < nb_fields; j++) { size =thunk_type_size (type_ptr, i);Where is the corresponding
free()?g_malloc()must be paired withg_free(), so you need to convert both places at once.
There is no corresponding free(). thunk_register_struct() is called only at startup from the linux-user code in order to populate the struct_entries array; this data structure then remains live for the entire lifetime of the program and is automatically freed when QEMU exits.
This is worth mentioning in the commit message, but the code is correct I think:
thanks
-- PMM
Quoted 14 lines · Peter Maydell
Quoted 5 lines
Quoted 5 lines
+++
b/thunk.cthunk.c +0
-0@@ -88,7 +88,7 @@ void thunk_register_struct(int id, const char *name, const argtype *types)for (i =0 ;i <2 ; i++) { offset =0 ; max_align =1 ;Quoted 8 lines
thunk.c void thunk_register_struct(int id, const char *name, const argtype *types) · line 94
Quoted 5 lines
thunk.c +1
-1- se->field_offsets[i] =malloc (nb_fields *sizeof (int )); + se->field_offsets[i] =g_malloc (nb_fields *sizeof (int )); type_ptr = se->field_types;for (j =0 ;j < nb_fields; j++) { size =thunk_type_size (type_ptr, i);Where is the corresponding
free()?g_malloc()must be paired withg_free(), so you need to convert both places at once.
Quoted 5 lines
There is no corresponding
free().thunk_register_struct()is called only at startup from the linux-user code in order to populate thestruct_entriesarray; this data structure then remains live for the entire lifetime of the program and is automatically freed when QEMU exits.
Fair enough. However, g_new(int, nb_fields) is probably a bit nicer than g_malloc() (in that it would detect multiplication overflow if nb_fields were ever oversized).
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 22 lines · Eric Blake
Quoted 14 lines · Peter Maydell
Quoted 5 lines
Quoted 5 lines
+++
b/thunk.cthunk.c +0
-0@@ -88,7 +88,7 @@ void thunk_register_struct(int id, const char *name, const argtype *types)for (i =0 ;i <2 ; i++) { offset =0 ; max_align =1 ;Quoted 8 lines
thunk.c void thunk_register_struct(int id, const char *name, const argtype *types) · line 94
Quoted 5 lines
thunk.c +1
-1- se->field_offsets[i] =malloc (nb_fields *sizeof (int )); + se->field_offsets[i] =g_malloc (nb_fields *sizeof (int )); type_ptr = se->field_types;for (j =0 ;j < nb_fields; j++) { size =thunk_type_size (type_ptr, i);Where is the corresponding
free()?g_malloc()must be paired withg_free(), so you need to convert both places at once.Quoted 5 lines
There is no corresponding
free().thunk_register_struct()is called only at startup from the linux-user code in order to populate thestruct_entriesarray; this data structure then remains live for the entire lifetime of the program and is automatically freed when QEMU exits.
Quoted 3 lines
Fair enough. However,
g_new(int, nb_fields)is probably a bit nicer thang_malloc()(in that it would detect multiplication overflow ifnb_fieldswere ever oversized).
Yes, good idea.
thanks
-- PMM
PATCH v2 1/1 [Qemu-devel] [PATCH v2][Outreachy Round 12]
In reply to Sarah KhanReplaced g_malloc() with g_new() as it would detect multiplication overflow if nb_fields ever oversize.
There is no corresponding free(). thunk_register_struct() is called only at startup from the linux-user code in order to populate the struct_entries array; this data structure then remains live for the entire lifetime of the program and is automatically freed when QEMU exits.
This replacement was suggested as part of the bite-sized tasks.
---
Changes in v2 :Make commit message clearer
Replace g_malloc() with g_new()
--- thunk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
thunk.c +1 -1
@@ -88,7 +88,7 @@ void thunk_register_struct(int id, const char *name, const argtype *types)for (i =0 ;i <2 ; i++) { offset =0 ; max_align =1 ; - se->field_offsets[i] =g_malloc (nb_fields *sizeof (int )); + se->field_offsets[i] =g_new (int,nb_fields); type_ptr = se->field_types;for (j =0 ;j < nb_fields; j++) { size =thunk_type_size (type_ptr, i);
Signature · 1 line
1.9.1
Re: [Qemu-devel] [PATCH v2][Outreachy Round 12]
Your commit message isn't quite right, yet. The first line is empty, which leads to
Subject: [PATCH v2][Outreachy Round 12]
in e-mail, which isn't really useful. It should be a line of the form
subsystem: Headline describing the patch briefly
In e-mail, this becomes something like
Subject: [PATCH v2] subsystem: Headline describing the patch briefly
The [PATCH v2] gets inserted by git-format-patch.
Finding the appropriate subsystem is unfortunately less than straightforward. You can use "git log --oneline FILENAME..." for ideas. For your patch, I'd use linux-user.
Since this is a rather busy list, it's important to cc the right people on patches. Start with "scripts/get_maintainer PATCH-FILE". The script looks up the files you patch in MAINTAINERS for you. In your case, its output is
Riku Voipio <[email protected]> (maintainer:Overall) [email protected] (open list:All patches CC here)
Send the patch to qemu-devel, cc: Riku.
All of this and much more is documented at
<http://wiki.qemu.org/Contribute/SubmitAPatch>. It's a learning curve, but we'll gladly help you along.
Quoted 1 line · Sarah Khan
Replaced
g_malloc()withg_new()as it would detect multiplication overflow ifnb_fieldsever oversize.
Long line, please break it like you do in the next paragraph.
Quoted 21 lines
There is no corresponding
free().thunk_register_struct()is called only at startup from the linux-user code in order to populate thestruct_entriesarray; this data structure then remains live for the entire lifetime of the program and is automatically freed when QEMU exits.This replacement was suggested as part of the bite-sized tasks.
Signed-off-by Sarah Khan <[email protected]>---
Changes in v2 :Make commit message clearer
Replaceg_malloc()withg_new()--- thunk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)thunk.c +0
-0
thunk.c void thunk_register_struct(int id, const char *name, const argtype *types) · line 94
Quoted 8 lines
thunk.c +1
-1@@ -88,7 +88,7 @@ void thunk_register_struct(int id, const char *name, const argtype *types)for (i =0 ;i <2 ; i++) { offset =0 ; max_align =1 ; - se->field_offsets[i] =g_malloc (nb_fields *sizeof (int )); + se->field_offsets[i] =g_new (int,nb_fields); type_ptr = se->field_types;for (j =0 ;j < nb_fields; j++) { size =thunk_type_size (type_ptr, i);
Oh, this is an *incremental* patch: it applies on top of your v1. That's awkward. Your v2 should *replace* v1, not add to it.
Style nitpick: we want a space after comma. Recommend to check your patches with scripts/checkpatch.pl. Output for this one is:
ERROR: space required after that ',' (ctx:VxV) #127: FILE: thunk.c:91:
+ se->field_offsets[i] = g_new(int,nb_fields);
^
total: 1 errors, 0 warnings, 8 lines checked
/home/armbru/Mail/mail/redhat/xlst/qemu-devel/385421 has style problems, please review. If any of these errors are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Welcome to qemu-devel, Sarah!
Re: [Qemu-devel] [PATCH v2][Outreachy Round 12]
Thank you for your feedback.
Will do the required.
Sorry for the delay as I was out of station.
Thanks,
Sarah
Quoted 91 lines · Markus Armbruster
Your commit message isn't quite right, yet. The first line is empty, which leads to
Subject: [PATCH v2][Outreachy Round 12]
in e-mail, which isn't really useful. It should be a line of the form
subsystem: Headline describing the patch briefly
In e-mail, this becomes something like
Subject: [PATCH v2] subsystem: Headline describing the patch briefly
The [PATCH v2] gets inserted by git-format-patch.
Finding the appropriate subsystem is unfortunately less than straightforward. You can use "git log --oneline FILENAME..." for ideas. For your patch, I'd use linux-user.
Since this is a rather busy list, it's important to cc the right people on patches. Start with "
scripts/get_maintainerPATCH-FILE". The script looks up the files you patch inMAINTAINERSfor you. In your case, its output isRiku Voipio <[email protected]> (maintainer:Overall) [email protected] (open list:All patches CC here)
Send the patch to qemu-devel, cc: Riku.
All of this and much more is documented at
<http://wiki.qemu.org/Contribute/SubmitAPatch>. It's a learning curve, but we'll gladly help you along.Quoted 1 line · Sarah Khan
Replaced
g_malloc()withg_new()as it would detect multiplicationoverflow if
nb_fieldsever oversize.Long line, please break it like you do in the next paragraph.
thunk.c void thunk_register_struct(int id, const char *name,
Quoted 21 lines
There is no corresponding
free().thunk_register_struct()is called only at startup from the linux-user code in order to populate thestruct_entriesarray; this data structure then remains live for the entire lifetime of the program and is automatically freed when QEMU exits.This replacement was suggested as part of the bite-sized tasks.
Signed-off-by Sarah Khan <[email protected]>---
Changes in v2 :Make commit message clearer
Replaceg_malloc()withg_new()--- thunk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)thunk.c +0
-0@@ -88,7 +88,7 @@ void thunk_register_struct(int id, const char *name,const argtype *types)
thunk.c void thunk_register_struct(int id, const char *name, const argtype *types) · line 94
Quoted 8 lines
thunk.c +1
-1for (i =0 ;i <2 ; i++) { offset =0 ; max_align =1 ; - se->field_offsets[i] =g_malloc (nb_fields *sizeof (int )); + se->field_offsets[i] =g_new (int,nb_fields); type_ptr = se->field_types;for (j =0 ;j < nb_fields; j++) { size =thunk_type_size (type_ptr, i);Oh, this is an *incremental* patch: it applies on top of your v1. That's awkward. Your v2 should *replace* v1, not add to it.
Style nitpick: we want a space after comma. Recommend to check your patches with
scripts/checkpatch.pl. Output for this one is:ERROR: space required after that ',' (ctx:VxV) #127: FILE: thunk.c:91:
+ se->field_offsets[i] =g_new(int,nb_fields);
^total: 1 errors, 0 warnings, 8 lines checked
/home/armbru/Mail/mail/redhat/xlst/qemu-devel/385421has style
problems, please review. If any of these errors
are false positives report them to the maintainer, see CHECKPATCH inMAINTAINERS.Welcome to qemu-devel, Sarah!