Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1475846
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 2/4] sparc: bpf_jit: Move four assignments in bpf_jit_compile() |
| Date | 2016-09-04 06:40 +0200 |
| Message-ID | <sdxnP-6fv-5@gated-at.bofh.it> (permalink) |
| References | <qEuGl-43C-5@gated-at.bofh.it> <sdm93-7Hd-19@gated-at.bofh.it> <sdm93-7Hd-17@gated-at.bofh.it> <sdwi6-5Ca-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
>> Date: Sat, 3 Sep 2016 17:45:28 +0200
>>
>> Move the assignments for four local variables a bit at the beginning
>> so that they will only be performed if a corresponding memory allocation
>> succeeded by this function.
…
>> @@ -362,10 +362,10 @@ do { *prog++ = BR_OPC | WDISP22(OFF); \
>>
>> void bpf_jit_compile(struct bpf_prog *fp)
>> {
>> - unsigned int cleanup_addr, proglen, oldproglen = 0;
>> - u32 temp[8], *prog, *func, seen = 0, pass;
>> - const struct sock_filter *filter = fp->insns;
>> - int i, flen = fp->len, pc_ret0 = -1;
>> + unsigned int cleanup_addr, proglen, oldproglen;
>> + u32 temp[8], *prog, *func, seen, pass;
>> + const struct sock_filter *filter;
>> + int i, flen = fp->len, pc_ret0;
>> unsigned int *addrs;
>> void *image;
>>
>> @@ -385,6 +385,10 @@ void bpf_jit_compile(struct bpf_prog *fp)
>> }
>> cleanup_addr = proglen; /* epilogue address */
>> image = NULL;
>> + filter = fp->insns;
>> + oldproglen = 0;
>> + pc_ret0 = -1;
>> + seen = 0;
>> for (pass = 0; pass < 10; pass++) {
>> u8 seen_or_pass0 = (pass == 0) ? (SEEN_XREG | SEEN_DATAREF | SEEN_MEM) : seen;
…
> If you were moving the assignments on declaration onto separate lines
> at the top of the file then ok,
I see another software design option where the transformation result might be looking
more pleasing for you again.
> but why all the way down here?
* How do you think about the reason I gave in the short commit message?
* Are you interested in an other software refactoring instead?
http://refactoring.com/catalog/reduceScopeOfVariable.html
Would you eventually like to move the source code for this for loop into another function?
http://refactoring.com/catalog/extractMethod.html
Regards,
Markus
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 2/4] sparc: bpf_jit: Move four assignments in bpf_jit_compile() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-03 18:40 +0200
Re: [PATCH 2/4] sparc: bpf_jit: Move four assignments in bpf_jit_compile() Julian Calaby <julian.calaby@gmail.com> - 2016-09-04 05:30 +0200
Re: [PATCH 2/4] sparc: bpf_jit: Move four assignments in bpf_jit_compile() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-04 06:40 +0200
Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-04 07:10 +0200
Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile() Julian Calaby <julian.calaby@gmail.com> - 2016-09-04 07:30 +0200
Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-04 07:50 +0200
Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile() Julian Calaby <julian.calaby@gmail.com> - 2016-09-04 08:10 +0200
Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-04 09:00 +0200
Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile() David Miller <davem@davemloft.net> - 2016-09-04 08:40 +0200
Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile() Julian Calaby <julian.calaby@gmail.com> - 2016-09-04 08:50 +0200
Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-04 09:10 +0200
Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile() Julian Calaby <julian.calaby@gmail.com> - 2016-09-04 09:20 +0200
Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile() David Miller <davem@davemloft.net> - 2016-09-04 08:50 +0200
Re: [PATCH 2/4] sparc: bpf_jit: Move four assignments in bpf_jit_compile() Julian Calaby <julian.calaby@gmail.com> - 2016-09-04 07:50 +0200
Re: [PATCH 2/4] sparc: bpf_jit: Move four assignments in bpf_jit_compile() Bjørn Mork <bjorn@mork.no> - 2016-09-04 21:40 +0200
csiph-web