Hi!
> +int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount)
> +{
> +     int fd, counter;
> +     char *buf;
> +
> +     fd = open(path, O_CREAT|O_WRONLY|O_TRUNC, S_IRUSR|S_IWUSR);
> +     if (fd < 0)
> +             return -1;
> +
> +     /* Filling a memory buffer with provided pattern */
> +     buf = malloc(bs);
> +     if (buf == NULL) {
> +             close(fd);
> +
> +             return -1;
> +     }
> +
> +     for (counter = 0; counter < bs; counter++)
> +             buf[counter] = pattern;
> +
> +     /* Filling the file */
> +     for (counter = 0; counter < bcount; counter++)
> +             if (write(fd, buf, bs) != bs) {
> +                     free(buf);
> +                     close(fd);
> +                     unlink(path);
> +
> +                     return -1;
> +             }

This is minor but I've told you allready that it's preffered to add the
curly brackets ({}) around large blocks. Such as:

        for (counter = 0; counter < bcount; counter++) {
                if (...) {
                        ...
                        ...
                }
        }

> +     free(buf);
> +     if (close(fd) < 0)

Add unlink here too, just to be consistent.

> +             return -1;
> +
> +     return 0;
> +}

Otherwise it looks good.

-- 
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to