clang-format

This commit is contained in:
2024-09-10 13:03:02 -04:00
parent 53c617d779
commit d66450e427
381 changed files with 28864 additions and 34170 deletions

View File

@@ -42,46 +42,43 @@
#include <fcntl.h>
#include <err.h>
int
main(int argc, char *argv[])
{
const char *filename;
int size;
int fd;
int r;
char byte;
int main(int argc, char *argv[]) {
const char *filename;
int size;
int fd;
int r;
char byte;
if (argc != 3) {
errx(1, "Usage: sparsefile <filename> <size>");
}
if (argc != 3) {
errx(1, "Usage: sparsefile <filename> <size>");
}
filename = argv[1];
size = atoi(argv[2]);
byte = '\n';
filename = argv[1];
size = atoi(argv[2]);
byte = '\n';
if (size == 0) {
err(1, "Sparse files of length zero are not meaningful");
}
if (size == 0) {
err(1, "Sparse files of length zero are not meaningful");
}
printf("Creating a sparse file of size %d\n", size);
printf("Creating a sparse file of size %d\n", size);
fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC);
if (fd < 0) {
err(1, "%s: create", filename);
}
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC);
if (fd < 0) {
err(1, "%s: create", filename);
}
if (lseek(fd, size-1, SEEK_SET) == -1) {
err(1, "%s: lseek", filename);
}
r = write(fd, &byte, 1);
if (r < 0) {
err(1, "%s: write", filename);
}
else if (r != 1) {
errx(1, "%s: write: Unexpected result count %d", filename, r);
}
if (lseek(fd, size - 1, SEEK_SET) == -1) {
err(1, "%s: lseek", filename);
}
r = write(fd, &byte, 1);
if (r < 0) {
err(1, "%s: write", filename);
} else if (r != 1) {
errx(1, "%s: write: Unexpected result count %d", filename, r);
}
close(fd);
close(fd);
return 0;
return 0;
}