aboutsummaryrefslogtreecommitdiffstats
path: root/tools/trasher.c
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2012-01-25 15:03:18 +0100
committerDiego Biurrun <diego@biurrun.de>2012-01-25 15:31:11 +0100
commit4e81b5f517443c0e60df3f2c6ddc8cac96a34af8 (patch)
tree16b9a1e1920ccbddcb870cc700189c7698341618 /tools/trasher.c
parent50639cbefef8cc9f3df19241be7cf23cde8313b7 (diff)
downloadffmpeg-4e81b5f517443c0e60df3f2c6ddc8cac96a34af8.tar.gz
tools: K&R reformatting cosmetics
Diffstat (limited to 'tools/trasher.c')
-rw-r--r--tools/trasher.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/tools/trasher.c b/tools/trasher.c
index e099aa30d6..11605b8a8e 100644
--- a/tools/trasher.c
+++ b/tools/trasher.c
@@ -23,47 +23,50 @@
#include <inttypes.h>
static uint32_t state;
-static uint32_t ran(void){
- return state= state*1664525+1013904223;
+static uint32_t ran(void)
+{
+ return state = state * 1664525 + 1013904223;
}
-int main(int argc, char** argv)
+int main(int argc, char **argv)
{
FILE *f;
int count, maxburst, length;
- if (argc < 5){
+ if (argc < 5) {
printf("USAGE: trasher <filename> <count> <maxburst> <seed>\n");
return 1;
}
- f= fopen(argv[1], "rb+");
- if (!f){
+ f = fopen(argv[1], "rb+");
+ if (!f) {
perror(argv[1]);
return 2;
}
- count= atoi(argv[2]);
- maxburst= atoi(argv[3]);
- state= atoi(argv[4]);
+ count = atoi(argv[2]);
+ maxburst = atoi(argv[3]);
+ state = atoi(argv[4]);
fseek(f, 0, SEEK_END);
- length= ftell(f);
+ length = ftell(f);
fseek(f, 0, SEEK_SET);
- while(count--){
- int burst= 1 + ran() * (uint64_t) (abs(maxburst)-1) / UINT32_MAX;
- int pos= ran() * (uint64_t) length / UINT32_MAX;
+ while (count--) {
+ int burst = 1 + ran() * (uint64_t) (abs(maxburst) - 1) / UINT32_MAX;
+ int pos = ran() * (uint64_t) length / UINT32_MAX;
fseek(f, pos, SEEK_SET);
- if(maxburst<0) burst= -maxburst;
+ if (maxburst < 0)
+ burst = -maxburst;
- if(pos + burst > length)
+ if (pos + burst > length)
continue;
- while(burst--){
- int val= ran() * 256ULL / UINT32_MAX;
+ while (burst--) {
+ int val = ran() * 256ULL / UINT32_MAX;
- if(maxburst<0) val=0;
+ if (maxburst < 0)
+ val = 0;
fwrite(&val, 1, 1, f);
}