Unify code style to preserve my sanity

This commit is contained in:
Unto Sten 2019-05-10 16:52:08 +03:00 committed by William Roberts
parent 5d8f44e2c3
commit e1a74396c7
9 changed files with 33 additions and 33 deletions

View File

@ -291,7 +291,7 @@ static int __policy_init(const char *init_path)
static PyObject *init(PyObject *self __attribute__((unused)), PyObject *args) {
int result;
char *init_path=NULL;
char *init_path = NULL;
if (avc) {
PyErr_SetString( PyExc_RuntimeError, "init called multiple times");
return NULL;
@ -322,7 +322,7 @@ static PyObject *analyze(PyObject *self __attribute__((unused)) , PyObject *args
sepol_access_vector_t perm, av;
struct sepol_av_decision avd;
int rc;
int i=0;
int i = 0;
if (!PyArg_ParseTuple(args,(char *)"sssO!:audit2why",&scon,&tcon,&tclassstr,&PyList_Type, &listObj))
return NULL;
@ -353,7 +353,7 @@ static PyObject *analyze(PyObject *self __attribute__((unused)) , PyObject *args
/* iterate over items of the list, grabbing strings, and parsing
for numbers */
for (i=0; i<numlines; i++){
for (i = 0; i < numlines; i++){
const char *permstr;
/* grab the string object from the next element of the list */
@ -395,13 +395,13 @@ static PyObject *analyze(PyObject *self __attribute__((unused)) , PyObject *args
} else {
PyObject *outboollist;
struct boolean_t *b = bools;
int len=0;
int len = 0;
while (b->name) {
len++; b++;
}
b = bools;
outboollist = PyList_New(len);
len=0;
len = 0;
while(b->name) {
PyObject *bool_ = Py_BuildValue("(si)", b->name, b->active);
PyList_SetItem(outboollist, len++, bool_);

View File

@ -125,10 +125,10 @@ char *selinux_boolean_sub(const char *name)
dst++;
if (!*dst)
continue;
ptr=dst;
ptr = dst;
while (*ptr && !isspace(*ptr))
ptr++;
*ptr='\0';
*ptr = '\0';
sub = strdup(dst);

View File

@ -83,8 +83,8 @@ hidden_def(selinuxfs_exists)
static void init_selinuxmnt(void)
{
char *buf=NULL, *p;
FILE *fp=NULL;
char *buf = NULL, *p;
FILE *fp = NULL;
size_t len;
ssize_t num;

View File

@ -635,10 +635,10 @@ static int selabel_subs_init(const char *path, struct selabel_digest *digest,
dst = ptr;
while (*dst && isspace(*dst))
dst++;
ptr=dst;
ptr = dst;
while (*ptr && ! isspace(*ptr))
ptr++;
*ptr='\0';
*ptr = '\0';
if (! *dst)
continue;
@ -647,11 +647,11 @@ static int selabel_subs_init(const char *path, struct selabel_digest *digest,
goto err;
memset(sub, 0, sizeof(*sub));
sub->src=strdup(src);
sub->src = strdup(src);
if (! sub->src)
goto err;
sub->dst=strdup(dst);
sub->dst = strdup(dst);
if (! sub->dst)
goto err;

View File

@ -143,7 +143,7 @@ unmap_perm(security_class_t tclass, access_vector_t tperm)
unsigned i;
access_vector_t kperm = 0;
for (i=0; i<current_mapping[tclass].num_perms; i++)
for (i = 0; i < current_mapping[tclass].num_perms; i++)
if (tperm & (1<<i)) {
kperm |= current_mapping[tclass].perms[i];
tperm &= ~(1<<i);
@ -169,7 +169,7 @@ map_class(security_class_t kclass)
{
security_class_t i;
for (i=0; i<current_mapping_size; i++)
for (i = 0; i < current_mapping_size; i++)
if (current_mapping[i].value == kclass)
return i;
@ -189,7 +189,7 @@ map_perm(security_class_t tclass, access_vector_t kperm)
unsigned i;
access_vector_t tperm = 0;
for (i=0; i<current_mapping[tclass].num_perms; i++)
for (i = 0; i < current_mapping[tclass].num_perms; i++)
if (kperm & current_mapping[tclass].perms[i]) {
tperm |= 1<<i;
kperm &= ~current_mapping[tclass].perms[i];

View File

@ -414,7 +414,7 @@ int realpath_not_final(const char *name, char *resolved_path)
if (len + strlen(last_component) + 2 > PATH_MAX) {
myprintf("symlink_realpath(%s) failed: Filename too long \n",
name);
errno=ENAMETOOLONG;
errno = ENAMETOOLONG;
rc = -1;
goto out;
}

View File

@ -274,7 +274,7 @@ int getseuser(const char *username, const char *service,
char *buffer = NULL;
size_t size = 0;
char *rec = NULL;
char *path=NULL;
char *path = NULL;
FILE *fp = NULL;
if (asprintf(&path,"%s/logins/%s", selinux_policy_root(), username) < 0)
goto err;

View File

@ -78,7 +78,7 @@ void
CHAR64LONG16 workspace;
CHAR64LONG16* block = &workspace;
memcpy( block, buffer, 64 );
memcpy(block, buffer, 64);
// Copy context->state[] to working vars
a = state[0];
@ -160,18 +160,18 @@ void hidden
uint32_t j;
j = (Context->Count[0] >> 3) & 63;
if( (Context->Count[0] += BufferSize << 3) < (BufferSize << 3) )
if ((Context->Count[0] += BufferSize << 3) < (BufferSize << 3))
{
Context->Count[1]++;
}
Context->Count[1] += (BufferSize >> 29);
if( (j + BufferSize) > 63 )
if ((j + BufferSize) > 63)
{
i = 64 - j;
memcpy( &Context->Buffer[j], Buffer, i );
memcpy(&Context->Buffer[j], Buffer, i);
TransformFunction(Context->State, Context->Buffer);
for( ; i + 63 < BufferSize; i += 64 )
for (; i + 63 < BufferSize; i += 64)
{
TransformFunction(Context->State, (uint8_t*)Buffer + i);
}
@ -182,7 +182,7 @@ void hidden
i = 0;
}
memcpy( &Context->Buffer[j], &((uint8_t*)Buffer)[i], BufferSize - i );
memcpy(&Context->Buffer[j], &((uint8_t*)Buffer)[i], BufferSize - i);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -201,19 +201,19 @@ void hidden
uint32_t i;
uint8_t finalcount[8];
for( i=0; i<8; i++ )
for (i = 0; i < 8; i++)
{
finalcount[i] = (unsigned char)((Context->Count[(i >= 4 ? 0 : 1)]
>> ((3-(i & 3)) * 8) ) & 255); // Endian independent
}
Sha1Update( Context, (uint8_t*)"\x80", 1 );
while( (Context->Count[0] & 504) != 448 )
Sha1Update(Context, (uint8_t*)"\x80", 1);
while ((Context->Count[0] & 504) != 448)
{
Sha1Update( Context, (uint8_t*)"\0", 1 );
Sha1Update(Context, (uint8_t*)"\0", 1);
}
Sha1Update( Context, finalcount, 8 ); // Should cause a Sha1TransformFunction()
for( i=0; i<SHA1_HASH_SIZE; i++ )
Sha1Update(Context, finalcount, 8); // Should cause a Sha1TransformFunction()
for (i = 0; i < SHA1_HASH_SIZE; i++)
{
Digest->bytes[i] = (uint8_t)((Context->State[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
}

View File

@ -147,7 +147,7 @@ static struct discover_class_node * discover_class(const char *s)
err4:
closedir(dir);
for (i=0; i<MAXVECTORS; i++)
for (i = 0; i < MAXVECTORS; i++)
free(node->perms[i]);
err3:
free(node->name);
@ -214,7 +214,7 @@ security_class_t mode_to_security_class(mode_t m) {
if (S_ISSOCK(m))
return string_to_security_class("sock_file");
errno=EINVAL;
errno = EINVAL;
return 0;
}
@ -226,7 +226,7 @@ access_vector_t string_to_av_perm(security_class_t tclass, const char *s)
node = get_class_cache_entry_value(kclass);
if (node != NULL) {
size_t i;
for (i=0; i<MAXVECTORS && node->perms[i] != NULL; i++)
for (i = 0; i < MAXVECTORS && node->perms[i] != NULL; i++)
if (strcmp(node->perms[i],s) == 0)
return map_perm(tclass, 1<<i);
}