policycoreutils: label_file: style changes to make Eric happy.
Sometimes sticking to 80 characters sucks a lot. I don't care. Buy a
wider monitor so I can read the code.
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Dan Walsh <dwalsh@redhat.com>
diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c
index 3b8346d..ac11b37 100644
--- a/libselinux/src/label_file.c
+++ b/libselinux/src/label_file.c
@@ -158,15 +158,12 @@
for (ii = 0; ii < data->nspec; ii++) {
curr_spec = &spec_arr[ii];
for (jj = ii + 1; jj < data->nspec; jj++) {
- if ((!strcmp
- (spec_arr[jj].regex_str, curr_spec->regex_str))
+ if ((!strcmp(spec_arr[jj].regex_str, curr_spec->regex_str))
&& (!spec_arr[jj].mode || !curr_spec->mode
|| spec_arr[jj].mode == curr_spec->mode)) {
rc = -1;
errno = EINVAL;
- if (strcmp
- (spec_arr[jj].lr.ctx_raw,
- curr_spec->lr.ctx_raw)) {
+ if (strcmp(spec_arr[jj].lr.ctx_raw, curr_spec->lr.ctx_raw)) {
COMPAT_LOG
(SELINUX_ERROR,
"%s: Multiple different specifications for %s (%s and %s).\n",
@@ -476,37 +473,41 @@
*/
maxnspec = UINT_MAX / sizeof(spec_t);
for (pass = 0; pass < 2; pass++) {
- lineno = 0;
data->nspec = 0;
data->ncomp = 0;
- while (getline(&line_buf, &line_len, fp) > 0
- && data->nspec < maxnspec) {
- if (process_line(rec, path, prefix, line_buf,
- pass, ++lineno) != 0)
+
+ lineno = 0;
+ while (getline(&line_buf, &line_len, fp) > 0) {
+ if (data->nspec >= maxnspec)
+ break;
+ status = process_line(rec, path, prefix, line_buf, pass, ++lineno);
+ if (status)
goto finish;
}
+
if (pass == 1 && rec->validating) {
status = nodups_specs(data, path);
if (status)
goto finish;
}
+
lineno = 0;
if (homedirfp)
- while (getline(&line_buf, &line_len, homedirfp) > 0
- && data->nspec < maxnspec) {
- if (process_line
- (rec, homedir_path, prefix,
- line_buf, pass, ++lineno) != 0)
+ while (getline(&line_buf, &line_len, homedirfp) > 0) {
+ if (data->nspec >= maxnspec)
+ break;
+ status = process_line(rec, homedir_path, prefix, line_buf, pass, ++lineno);
+ if (status)
goto finish;
}
lineno = 0;
if (localfp)
- while (getline(&line_buf, &line_len, localfp) > 0
- && data->nspec < maxnspec) {
- if (process_line
- (rec, local_path, prefix, line_buf,
- pass, ++lineno) != 0)
+ while (getline(&line_buf, &line_len, localfp) > 0) {
+ if (data->nspec >= maxnspec)
+ break;
+ status = process_line(rec, local_path, prefix, line_buf, pass, ++lineno);
+ if (status)
goto finish;
}
@@ -515,10 +516,10 @@
status = 0;
goto finish;
}
- if (NULL == (data->spec_arr =
- malloc(sizeof(spec_t) * data->nspec)))
+ data->spec_arr = calloc(data->nspec, sizeof(spec_t));
+ if (!data->spec_arr)
goto finish;
- memset(data->spec_arr, 0, sizeof(spec_t)*data->nspec);
+
maxnspec = data->nspec;
rewind(fp);
if (homedirfp)