diff options
author | Steven Rostedt <srostedt@redhat.com> | 2012-05-11 23:28:49 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2012-05-16 16:18:57 -0400 |
commit | 6edb2a8a385f0cdef51dae37ff23e74d76d8a6ce (patch) | |
tree | 80a8bf8b301984907bd8773ca31748e82e136638 /kernel/trace/trace.c | |
parent | 978da300c7a65494692b329a6a4cbf364afc37c5 (diff) |
tracing: Clean up tracing_mark_write()
On gcc 4.5 the function tracing_mark_write() would give a warning
of page2 being uninitialized. This is due to a bug in gcc because
the logic prevents page2 from being used uninitialized, and
gcc 4.6+ does not complain (correctly).
Instead of adding a "unitialized" around page2, which could show
a bug later on, I combined page1 and page2 into an array map_pages[].
This binds the two and the two are modified according to nr_pages
(what gcc 4.5 seems to ignore). This no longer gives a warning with
gcc 4.5 nor with gcc 4.6.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 48ef4960ec90..d1b3469b62e3 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -3875,14 +3875,14 @@ tracing_mark_write(struct file *filp, const char __user *ubuf, | |||
3875 | struct print_entry *entry; | 3875 | struct print_entry *entry; |
3876 | unsigned long irq_flags; | 3876 | unsigned long irq_flags; |
3877 | struct page *pages[2]; | 3877 | struct page *pages[2]; |
3878 | void *map_page[2]; | ||
3878 | int nr_pages = 1; | 3879 | int nr_pages = 1; |
3879 | ssize_t written; | 3880 | ssize_t written; |
3880 | void *page1; | ||
3881 | void *page2; | ||
3882 | int offset; | 3881 | int offset; |
3883 | int size; | 3882 | int size; |
3884 | int len; | 3883 | int len; |
3885 | int ret; | 3884 | int ret; |
3885 | int i; | ||
3886 | 3886 | ||
3887 | if (tracing_disabled) | 3887 | if (tracing_disabled) |
3888 | return -EINVAL; | 3888 | return -EINVAL; |
@@ -3921,9 +3921,8 @@ tracing_mark_write(struct file *filp, const char __user *ubuf, | |||
3921 | goto out; | 3921 | goto out; |
3922 | } | 3922 | } |
3923 | 3923 | ||
3924 | page1 = kmap_atomic(pages[0]); | 3924 | for (i = 0; i < nr_pages; i++) |
3925 | if (nr_pages == 2) | 3925 | map_page[i] = kmap_atomic(pages[i]); |
3926 | page2 = kmap_atomic(pages[1]); | ||
3927 | 3926 | ||
3928 | local_save_flags(irq_flags); | 3927 | local_save_flags(irq_flags); |
3929 | size = sizeof(*entry) + cnt + 2; /* possible \n added */ | 3928 | size = sizeof(*entry) + cnt + 2; /* possible \n added */ |
@@ -3941,10 +3940,10 @@ tracing_mark_write(struct file *filp, const char __user *ubuf, | |||
3941 | 3940 | ||
3942 | if (nr_pages == 2) { | 3941 | if (nr_pages == 2) { |
3943 | len = PAGE_SIZE - offset; | 3942 | len = PAGE_SIZE - offset; |
3944 | memcpy(&entry->buf, page1 + offset, len); | 3943 | memcpy(&entry->buf, map_page[0] + offset, len); |
3945 | memcpy(&entry->buf[len], page2, cnt - len); | 3944 | memcpy(&entry->buf[len], map_page[1], cnt - len); |
3946 | } else | 3945 | } else |
3947 | memcpy(&entry->buf, page1 + offset, cnt); | 3946 | memcpy(&entry->buf, map_page[0] + offset, cnt); |
3948 | 3947 | ||
3949 | if (entry->buf[cnt - 1] != '\n') { | 3948 | if (entry->buf[cnt - 1] != '\n') { |
3950 | entry->buf[cnt] = '\n'; | 3949 | entry->buf[cnt] = '\n'; |
@@ -3959,11 +3958,10 @@ tracing_mark_write(struct file *filp, const char __user *ubuf, | |||
3959 | *fpos += written; | 3958 | *fpos += written; |
3960 | 3959 | ||
3961 | out_unlock: | 3960 | out_unlock: |
3962 | if (nr_pages == 2) | 3961 | for (i = 0; i < nr_pages; i++){ |
3963 | kunmap_atomic(page2); | 3962 | kunmap_atomic(map_page[i]); |
3964 | kunmap_atomic(page1); | 3963 | put_page(pages[i]); |
3965 | while (nr_pages > 0) | 3964 | } |
3966 | put_page(pages[--nr_pages]); | ||
3967 | out: | 3965 | out: |
3968 | return written; | 3966 | return written; |
3969 | } | 3967 | } |