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

@@ -39,106 +39,94 @@
/*
* Wrapper around malloc.
*/
void *
domalloc(size_t len)
{
void *x;
x = malloc(len);
if (x==NULL) {
errx(EXIT_FATAL, "Out of memory");
}
return x;
void *domalloc(size_t len) {
void *x;
x = malloc(len);
if (x == NULL) {
errx(EXIT_FATAL, "Out of memory");
}
return x;
}
/*
* Wrapper around realloc. OSZ is the old block size, which we need if
* we're going to emulate realloc with malloc.
*/
void *
dorealloc(void *op, size_t osz, size_t nsz)
{
void *np;
void *dorealloc(void *op, size_t osz, size_t nsz) {
void *np;
#ifdef NO_REALLOC
size_t copysz;
size_t copysz;
np = domalloc(nsz);
if (op != NULL) {
copysz = osz < nsz ? osz : nsz;
memcpy(np, op, copysz);
free(op);
}
np = domalloc(nsz);
if (op != NULL) {
copysz = osz < nsz ? osz : nsz;
memcpy(np, op, copysz);
free(op);
}
#else
(void)osz;
np = realloc(op, nsz);
if (np == NULL) {
errx(EXIT_FATAL, "Out of memory");
}
(void)osz;
np = realloc(op, nsz);
if (np == NULL) {
errx(EXIT_FATAL, "Out of memory");
}
#endif
return np;
return np;
}
/*
* Get a unique id number. (unique as in for this run of sfsck...)
*/
uint32_t
uniqueid(void)
{
static uint32_t uniquecounter;
uint32_t uniqueid(void) {
static uint32_t uniquecounter;
return uniquecounter++;
return uniquecounter++;
}
/*
* Check if BUF, a string field of length MAXLEN, contains a null
* terminator. If not, slam one in and return 1.
*/
int
checknullstring(char *buf, size_t maxlen)
{
size_t i;
for (i=0; i<maxlen; i++) {
if (buf[i]==0) {
return 0;
}
}
buf[maxlen-1] = 0;
return 1;
int checknullstring(char *buf, size_t maxlen) {
size_t i;
for (i = 0; i < maxlen; i++) {
if (buf[i] == 0) {
return 0;
}
}
buf[maxlen - 1] = 0;
return 1;
}
/*
* Check if BUF contains characters not allowed in file and volume
* names. If so, stomp them and return 1.
*/
int
checkbadstring(char *buf)
{
size_t i;
int rv = 0;
int checkbadstring(char *buf) {
size_t i;
int rv = 0;
for (i=0; buf[i]; i++) {
if (buf[i]==':' || buf[i]=='/') {
buf[i] = '_';
rv = 1;
}
}
return rv;
for (i = 0; buf[i]; i++) {
if (buf[i] == ':' || buf[i] == '/') {
buf[i] = '_';
rv = 1;
}
}
return rv;
}
/*
* Check if BUF, of size LEN, is zeroed. If not, zero it and return 1.
*/
int
checkzeroed(void *vbuf, size_t len)
{
char *buf = vbuf;
size_t i;
int rv = 0;
int checkzeroed(void *vbuf, size_t len) {
char *buf = vbuf;
size_t i;
int rv = 0;
for (i=0; i < len; i++) {
if (buf[i] != 0) {
buf[i] = 0;
rv = 1;
}
}
return rv;
for (i = 0; i < len; i++) {
if (buf[i] != 0) {
buf[i] = 0;
rv = 1;
}
}
return rv;
}