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.
Showing the changes to kernel (1 of 1 file). Show all
Unified · Split
| @@ -3875,14 +3875,14 @@ tracing_mark_write(struct file *filp, const char __user *ubuf, · 3874 unmodified lines | ||
| 3875 | 3875 | struct print_entry *entry; |
| 3876 | 3876 | unsigned long irq_flags; |
| 3877 | 3877 | struct page *pages[2]; |
| 3878 | + void *map_page[2]; | |
| 3878 | 3879 | int nr_pages = 1; |
| 3879 | 3880 | ssize_t written; |
| 3880 | − void *page1; | |
| 3881 | − void *page2; | |
| 3882 | 3881 | int offset; |
| 3883 | 3882 | int size; |
| 3884 | 3883 | int len; |
| 3885 | 3884 | int ret; |
| 3885 | + int i; | |
| 3886 | 3886 | |
| 3887 | 3887 | if (tracing_disabled) |
| 3888 | 3888 | return -EINVAL; |
| @@ -3921,9 +3921,8 @@ tracing_mark_write(struct file *filp, const char __user *ubuf, · 32 unmodified lines | ||
| 3921 | 3921 | goto out; |
| 3922 | 3922 | } |
| 3923 | 3923 | |
| 3924 | − page1 = kmap_atomic(pages[0]); | |
| 3925 | − if (nr_pages == 2) | |
| 3926 | − page2 = kmap_atomic(pages[1]); | |
| 3924 | + for (i = 0; i < nr_pages; i++) | |
| 3925 | + map_page[i] = kmap_atomic(pages[i]); | |
| 3927 | 3926 | |
| 3928 | 3927 | local_save_flags(irq_flags); |
| 3929 | 3928 | size = sizeof(*entry) + cnt + 2; /* possible \n added */ |
| @@ -3941,10 +3940,10 @@ tracing_mark_write(struct file *filp, const char __user *ubuf, · 11 unmodified lines | ||
| 3941 | 3940 | |
| 3942 | 3941 | if (nr_pages == 2) { |
| 3943 | 3942 | len = PAGE_SIZE - offset; |
| 3944 | − memcpy(&entry->buf, page1 + offset, len); | |
| 3945 | − memcpy(&entry->buf[len], page2, cnt - len); | |
| 3943 | + memcpy(&entry->buf, map_page[0] + offset, len); | |
| 3944 | + memcpy(&entry->buf[len], map_page[1], cnt - len); | |
| 3946 | 3945 | } else |
| 3947 | − memcpy(&entry->buf, page1 + offset, cnt); | |
| 3946 | + memcpy(&entry->buf, map_page[0] + offset, cnt); | |
| 3948 | 3947 | |
| 3949 | 3948 | if (entry->buf[cnt - 1] != '\n') { |
| 3950 | 3949 | entry->buf[cnt] = '\n'; |
| @@ -3959,11 +3958,10 @@ tracing_mark_write(struct file *filp, const char __user *ubuf, · 8 unmodified lines | ||
| 3959 | 3958 | *fpos += written; |
| 3960 | 3959 | |
| 3961 | 3960 | out_unlock: |
| 3962 | − if (nr_pages == 2) | |
| 3963 | − kunmap_atomic(page2); | |
| 3964 | − kunmap_atomic(page1); | |
| 3965 | − while (nr_pages > 0) | |
| 3966 | − put_page(pages[--nr_pages]); | |
| 3961 | + for (i = 0; i < nr_pages; i++){ | |
| 3962 | + kunmap_atomic(map_page[i]); | |
| 3963 | + put_page(pages[i]); | |
| 3964 | + } | |
| 3967 | 3965 | out: |
| 3968 | 3966 | return written; |
| 3969 | 3967 | } |