(libT) copyediting: reformat blocklist.c to the new indentation style
This commit is contained in:
parent
29d6f5d934
commit
1ece2b3f98
|
@ -66,7 +66,7 @@ struct tr_blocklist
|
|||
static void
|
||||
blocklistClose (tr_blocklist * b)
|
||||
{
|
||||
if (b->rules)
|
||||
if (b->rules != NULL)
|
||||
{
|
||||
munmap (b->rules, b->byteCount);
|
||||
close (b->fd);
|
||||
|
@ -83,6 +83,7 @@ blocklistLoad (tr_blocklist * b)
|
|||
int fd;
|
||||
size_t byteCount;
|
||||
struct stat st;
|
||||
char * base;
|
||||
const char * err_fmt = _("Couldn't read \"%1$s\": %2$s");
|
||||
|
||||
blocklistClose (b);
|
||||
|
@ -110,23 +111,20 @@ blocklistLoad (tr_blocklist * b)
|
|||
b->byteCount = byteCount;
|
||||
b->ruleCount = byteCount / sizeof (struct tr_ipv4_range);
|
||||
|
||||
{
|
||||
char * base = tr_basename (b->filename);
|
||||
base = tr_basename (b->filename);
|
||||
tr_inf (_("Blocklist \"%s\" contains %zu entries"), base, b->ruleCount);
|
||||
tr_free (base);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
blocklistEnsureLoaded (tr_blocklist * b)
|
||||
{
|
||||
if (!b->rules)
|
||||
if (b->rules == NULL)
|
||||
blocklistLoad (b);
|
||||
}
|
||||
|
||||
static int
|
||||
compareAddressToRange (const void * va,
|
||||
const void * vb)
|
||||
compareAddressToRange (const void * va, const void * vb)
|
||||
{
|
||||
const uint32_t * a = va;
|
||||
const struct tr_ipv4_range * b = vb;
|
||||
|
@ -334,7 +332,7 @@ _tr_blocklistSetContent (tr_blocklist * b, const char * filename)
|
|||
}
|
||||
|
||||
in = fopen (filename, "rb");
|
||||
if (!in)
|
||||
if (in == NULL)
|
||||
{
|
||||
tr_err (err_fmt, filename, tr_strerror (errno));
|
||||
return 0;
|
||||
|
@ -343,7 +341,7 @@ _tr_blocklistSetContent (tr_blocklist * b, const char * filename)
|
|||
blocklistClose (b);
|
||||
|
||||
out = fopen (b->filename, "wb+");
|
||||
if (!out)
|
||||
if (out == NULL)
|
||||
{
|
||||
tr_err (err_fmt, b->filename, tr_strerror (errno));
|
||||
fclose (in);
|
||||
|
@ -414,8 +412,11 @@ _tr_blocklistSetContent (tr_blocklist * b, const char * filename)
|
|||
}
|
||||
|
||||
if (fwrite (ranges, sizeof (struct tr_ipv4_range), ranges_count, out) != ranges_count)
|
||||
{
|
||||
tr_err (_("Couldn't save file \"%1$s\": %2$s"), b->filename, tr_strerror (errno));
|
||||
else {
|
||||
}
|
||||
else
|
||||
{
|
||||
char * base = tr_basename (b->filename);
|
||||
tr_inf (_("Blocklist \"%s\" updated with %zu entries"), base, ranges_count);
|
||||
tr_free (base);
|
||||
|
|
Loading…
Reference in New Issue