lkml.org 
[lkml]   [2021]   [Jun]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH V4 06/12] trace: Add a generic function to read/write u64 values from tracefs
    On Tue, 15 Jun 2021 11:28:45 +0200
    Daniel Bristot de Oliveira <bristot@redhat.com> wrote:
    > +static ssize_t
    > +trace_min_max_read(struct file *filp, char __user *ubuf, size_t cnt,
    > + loff_t *ppos)
    > +{
    > + struct trace_min_max_param *param = filp->private_data;
    > + char buf[ULL_STR_SIZE];
    > + u64 val;
    > + int len;

    White space issue above?

    > +
    > + if (!param)
    > + return -EFAULT;

    And above here too?


    > +
    > + val = *param->val;
    > +
    > + if (cnt > sizeof(buf))
    > + cnt = sizeof(buf);
    > +
    > + len = snprintf(buf, sizeof(buf), "%llu\n", val);
    > +
    > + return simple_read_from_buffer(ubuf, cnt, ppos, buf, len);

    Egad, this entire patch is filled with whitespace issues!

    Please check your other patches too.

    > +}
    > +


    > +
    > +#define ULL_STR_SIZE 22 /* 20 digits max */

    Nit. I'd make this 24, just to be integer aligned. I mean, it's used as:


    trace_min_max_read(struct file *filp, char __user *ubuf, size_t cnt,
    loff_t *ppos)
    {
    struct trace_min_max_param *param = filp->private_data;
    char buf[ULL_STR_SIZE];
    u64 val;
    int len;

    Probably should reverse the above as well, that way if you do have
    ULL_STR_SIZE as 24, then the int len, will fit right in before the u64
    val. Although, I think compilers are free to optimize that too :-/

    -- Steve

    \
     
     \ /
      Last update: 2021-06-18 18:57    [W:2.501 / U:0.020 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site