Skip to content

Commit

Permalink
Fix control statement style
Browse files Browse the repository at this point in the history
  • Loading branch information
bdrewery committed Jun 7, 2012
1 parent 94aa0a8 commit 7aa1081
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions libpkg/packing.c
Expand Up @@ -76,7 +76,7 @@ packing_init(struct packing **pack, const char *path, pkg_formats format)
snprintf(archive_path, sizeof(archive_path), "%s.%s", path, ext);

if (archive_write_open_filename(
(*pack)->awrite, archive_path) != ARCHIVE_OK ) {
(*pack)->awrite, archive_path) != ARCHIVE_OK) {
pkg_emit_errno("archive_write_open_filename",
archive_path);
archive_read_finish((*pack)->aread);
Expand Down Expand Up @@ -202,7 +202,7 @@ packing_append_file_attr(struct packing *pack, const char *filepath, const char
goto cleanup;
}

while ((len = read(fd, buf, sizeof(buf))) > 0 )
while ((len = read(fd, buf, sizeof(buf))) > 0)
archive_write_data(pack->awrite, buf, len);

close(fd);
Expand Down
2 changes: 1 addition & 1 deletion libpkg/pkg.c
Expand Up @@ -1030,7 +1030,7 @@ pkg_open2(struct pkg **pkg_p, struct archive **a, struct archive_entry **ae, con
if (strcmp(fpath, files[i].name) == 0) {
sbuf = &pkg->fields[files[i].attr];
sbuf_init(sbuf);
while ((size = archive_read_data(*a, buf, sizeof(buf))) > 0 ) {
while ((size = archive_read_data(*a, buf, sizeof(buf))) > 0) {
sbuf_bcat(*sbuf, buf, size);
}
sbuf_finish(*sbuf);
Expand Down
4 changes: 2 additions & 2 deletions libpkg/pkg_attributes.c
Expand Up @@ -158,7 +158,7 @@ pkg_dir_try(struct pkg_dir *d)
int
pkg_category_new(struct pkg_category **c)
{
if (( *c = calloc(1, sizeof(struct pkg_category))) == NULL)
if ((*c = calloc(1, sizeof(struct pkg_category))) == NULL)
return (EPKG_FATAL);

return (EPKG_OK);
Expand Down Expand Up @@ -364,7 +364,7 @@ pkg_option_value(struct pkg_option *option)
int
pkg_shlib_new(struct pkg_shlib **sl)
{
if (( *sl = calloc(1, sizeof(struct pkg_shlib))) == NULL)
if ((*sl = calloc(1, sizeof(struct pkg_shlib))) == NULL)
return (EPKG_FATAL);

return (EPKG_OK);
Expand Down
10 changes: 5 additions & 5 deletions libpkg/pkg_config.c
Expand Up @@ -177,7 +177,7 @@ parse_configuration(yaml_document_t *doc, yaml_node_t *node)
continue;
}

if (val->type == YAML_NO_NODE || ( val->type == YAML_SCALAR_NODE && val->data.scalar.length <= 0)) {
if (val->type == YAML_NO_NODE || (val->type == YAML_SCALAR_NODE && val->data.scalar.length <= 0)) {
/* silently skip on purpose */
++pair;
continue;
Expand Down Expand Up @@ -256,14 +256,14 @@ pkg_config_bool(pkg_config_key key, bool *val)

if (c[key].val != NULL && (
strcasecmp(c[key].val, "yes") == 0 ||
strcasecmp(c[key].val, "true" ) == 0 ||
strcasecmp(c[key].val, "on" ) == 0)) {
strcasecmp(c[key].val, "true") == 0 ||
strcasecmp(c[key].val, "on") == 0)) {
*val = true;
}
else if (c[key].val == NULL && c[key].def != NULL && (
strcasecmp(c[key].def, "yes") == 0 ||
strcasecmp(c[key].def, "true" ) == 0 ||
strcasecmp(c[key].def, "on" ) == 0)) {
strcasecmp(c[key].def, "true") == 0 ||
strcasecmp(c[key].def, "on") == 0)) {
*val = true;
}

Expand Down
2 changes: 1 addition & 1 deletion libpkg/pkg_delete.c
Expand Up @@ -90,7 +90,7 @@ pkg_delete(struct pkg *pkg, struct pkgdb *db, int flags)
pkg_start_stop_rc_scripts(pkg, PKG_RC_STOP);

if (flags & PKG_DELETE_UPGRADE) {
if (( ret = pkg_script_run(pkg, PKG_SCRIPT_PRE_UPGRADE)) != EPKG_OK )
if ((ret = pkg_script_run(pkg, PKG_SCRIPT_PRE_UPGRADE)) != EPKG_OK)
return (ret);
} else {
if ((ret = pkg_script_run(pkg, PKG_SCRIPT_PRE_DEINSTALL)) != EPKG_OK)
Expand Down
8 changes: 4 additions & 4 deletions libpkg/pkg_elf.c
Expand Up @@ -151,7 +151,7 @@ analyse_elf(struct pkgdb *db, struct pkg *pkg, const char *fpath)
goto cleanup;
}

if (( e = elf_begin(fd, ELF_C_READ, NULL)) == NULL) {
if ((e = elf_begin(fd, ELF_C_READ, NULL)) == NULL) {
ret = EPKG_FATAL;
pkg_emit_error("elf_begin() for %s failed: %s", fpath, elf_errmsg(-1));
goto cleanup;
Expand All @@ -176,7 +176,7 @@ analyse_elf(struct pkgdb *db, struct pkg *pkg, const char *fpath)
goto cleanup;
}

while (( scn = elf_nextscn(e, scn)) != NULL) {
while ((scn = elf_nextscn(e, scn)) != NULL) {
if (gelf_getshdr(scn, &shdr) != &shdr) {
ret = EPKG_FATAL;
pkg_emit_error("getshdr() for %s failed: %s", fpath, elf_errmsg(-1));
Expand Down Expand Up @@ -235,7 +235,7 @@ analyse_elf(struct pkgdb *db, struct pkg *pkg, const char *fpath)
}

cleanup:
if ( e != NULL)
if (e != NULL)
elf_end(e);
close(fd);

Expand Down Expand Up @@ -292,7 +292,7 @@ pkg_analyse_files(struct pkgdb *db, struct pkg *pkg)
fpath = pkg_file_get(file, PKG_FILE_PATH);
ret = analyse_elf(db, pkg, fpath);
if (developer) {
if ( ret != EPKG_OK && ret != EPKG_END )
if (ret != EPKG_OK && ret != EPKG_END)
return (ret);
analyse_fpath(pkg, fpath);
}
Expand Down
6 changes: 3 additions & 3 deletions libpkg/pkg_manifest.c
Expand Up @@ -210,9 +210,9 @@ pkg_set_licenselogic_from_node(struct pkg *pkg, yaml_node_t *val, __unused yaml_
{
if (!strcmp(val->data.scalar.value, "single"))
pkg_set(pkg, PKG_LICENSE_LOGIC, (int64_t) LICENSE_SINGLE);
else if ( !strcmp(val->data.scalar.value, "and") || !strcmp(val->data.scalar.value, "dual"))
else if (!strcmp(val->data.scalar.value, "and") || !strcmp(val->data.scalar.value, "dual"))
pkg_set(pkg, PKG_LICENSE_LOGIC, (int64_t)LICENSE_AND);
else if ( !strcmp(val->data.scalar.value, "or") || !strcmp(val->data.scalar.value, "multi"))
else if (!strcmp(val->data.scalar.value, "or") || !strcmp(val->data.scalar.value, "multi"))
pkg_set(pkg, PKG_LICENSE_LOGIC, (int64_t)LICENSE_OR);
else {
pkg_emit_error("Unknown license logic: %s", val->data.scalar.value);
Expand Down Expand Up @@ -571,7 +571,7 @@ parse_root_node(struct pkg *pkg, yaml_node_t *node, yaml_document_t *doc) {
continue;
}

if (val->type == YAML_NO_NODE || ( val->type == YAML_SCALAR_NODE && val->data.scalar.length <= 0)) {
if (val->type == YAML_NO_NODE || (val->type == YAML_SCALAR_NODE && val->data.scalar.length <= 0)) {
/* silently skip on purpose */
++pair;
continue;
Expand Down
2 changes: 1 addition & 1 deletion libpkg/pkg_repo.c
Expand Up @@ -429,7 +429,7 @@ pkg_create_repo(char *path, void (progress)(struct pkg *pkg, void *data), void *

pkg_path = ent->fts_path;
pkg_path += strlen(path);
while (pkg_path[0] == '/' )
while (pkg_path[0] == '/')
pkg_path++;

sha256_file(ent->fts_accpath, cksum);
Expand Down
24 changes: 12 additions & 12 deletions libpkg/pkgdb.c
Expand Up @@ -118,7 +118,7 @@ load_val(sqlite3 *db, struct pkg *pkg, const char *sql, int flags, int (*pkg_add

sqlite3_bind_int64(stmt, 1, pkg->rowid);

while (( ret = sqlite3_step(stmt)) == SQLITE_ROW) {
while ((ret = sqlite3_step(stmt)) == SQLITE_ROW) {
pkg_adddata(pkg, sqlite3_column_text(stmt, 0));
}

Expand Down Expand Up @@ -181,7 +181,7 @@ populate_pkg(sqlite3_stmt *stmt, struct pkg *pkg) {
colname = sqlite3_column_name(stmt, icol);
switch (sqlite3_column_type(stmt, icol)) {
case SQLITE_TEXT:
for (i = 0; columns[i].name != NULL; i++ ) {
for (i = 0; columns[i].name != NULL; i++) {
if (!strcmp(columns[i].name, colname)) {
pkg_set(pkg, columns[i].type, sqlite3_column_text(stmt, icol));
break;
Expand All @@ -191,7 +191,7 @@ populate_pkg(sqlite3_stmt *stmt, struct pkg *pkg) {
pkg_emit_error("Unknown column %s", colname);
break;
case SQLITE_INTEGER:
for (i = 0; columns[i].name != NULL; i++ ) {
for (i = 0; columns[i].name != NULL; i++) {
if (!strcmp(columns[i].name, colname)) {
pkg_set(pkg, columns[i].type, sqlite3_column_int64(stmt, icol));
break;
Expand Down Expand Up @@ -1185,7 +1185,7 @@ pkgdb_load_dirs(struct pkgdb *db, struct pkg *pkg)

sqlite3_bind_int64(stmt, 1, pkg->rowid);

while (( ret = sqlite3_step(stmt)) == SQLITE_ROW) {
while ((ret = sqlite3_step(stmt)) == SQLITE_ROW) {
pkg_adddir(pkg, sqlite3_column_text(stmt, 0), sqlite3_column_int(stmt, 1));
}

Expand Down Expand Up @@ -1641,7 +1641,7 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg, int complete)
if ((it = pkgdb_query_which(db, pkg_file_get(file, PKG_FILE_PATH))) == NULL) {
ERROR_SQLITE(s);
}
if (( ret = pkgdb_it_next(it, &pkg2, PKG_LOAD_BASIC)) == EPKG_OK) {
if ((ret = pkgdb_it_next(it, &pkg2, PKG_LOAD_BASIC)) == EPKG_OK) {
pkg_get(pkg2, PKG_NAME, &name2, PKG_VERSION, &version2);
pkg_emit_error("%s-%s conflicts with %s-%s"
" (installs files into the same place). "
Expand Down Expand Up @@ -1688,7 +1688,7 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg, int complete)
goto cleanup;
}
if ((ret = sqlite3_step(stmt2)) != SQLITE_DONE) {
if ( ret == SQLITE_CONSTRAINT) {
if (ret == SQLITE_CONSTRAINT) {
pkg_emit_error("A package is already providing this directory: %s", pkg_dir_path(dir));
} else
ERROR_SQLITE(s);
Expand Down Expand Up @@ -1728,7 +1728,7 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg, int complete)
ERROR_SQLITE(s);
goto cleanup;
}
if (( ret = sqlite3_step(stmt)) != SQLITE_DONE) {
if ((ret = sqlite3_step(stmt)) != SQLITE_DONE) {
ERROR_SQLITE(s);
goto cleanup;
}
Expand Down Expand Up @@ -1765,7 +1765,7 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg, int complete)
ERROR_SQLITE(s);
goto cleanup;
}
if (( ret = sqlite3_step(stmt)) != SQLITE_DONE) {
if ((ret = sqlite3_step(stmt)) != SQLITE_DONE) {
ERROR_SQLITE(s);
goto cleanup;
}
Expand Down Expand Up @@ -1802,7 +1802,7 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg, int complete)
ERROR_SQLITE(s);
goto cleanup;
}
if (( ret = sqlite3_step(stmt2)) != SQLITE_DONE) {
if ((ret = sqlite3_step(stmt2)) != SQLITE_DONE) {
ERROR_SQLITE(s);
goto cleanup;
}
Expand Down Expand Up @@ -1839,7 +1839,7 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg, int complete)
ERROR_SQLITE(s);
goto cleanup;
}
if (( ret = sqlite3_step(stmt2)) != SQLITE_DONE) {
if ((ret = sqlite3_step(stmt2)) != SQLITE_DONE) {
ERROR_SQLITE(s);
goto cleanup;
}
Expand Down Expand Up @@ -1923,7 +1923,7 @@ pkgdb_register_pkg(struct pkgdb *db, struct pkg *pkg, int complete)
ERROR_SQLITE(s);
goto cleanup;
}
if (( ret = sqlite3_step(stmt2)) != SQLITE_DONE) {
if ((ret = sqlite3_step(stmt2)) != SQLITE_DONE) {
ERROR_SQLITE(s);
goto cleanup;
}
Expand Down Expand Up @@ -2894,7 +2894,7 @@ pkgdb_integrity_append(struct pkgdb *db, struct pkg *p)
"values (?1, ?2, ?3, ?4);";
const char sql_conflicts[] = "SELECT name, version from integritycheck where path=?1;";

assert( db != NULL && p != NULL);
assert(db != NULL && p != NULL);

sql_exec(db->sqlite, "CREATE TEMP TABLE IF NOT EXISTS integritycheck ( "
"name TEXT, "
Expand Down
2 changes: 1 addition & 1 deletion libpkg/rsa.c
Expand Up @@ -69,7 +69,7 @@ _load_rsa_public_key(const char *rsa_key_path)
return (NULL);
}

if (!PEM_read_RSA_PUBKEY( fp, &rsa, NULL, NULL )) {
if (!PEM_read_RSA_PUBKEY(fp, &rsa, NULL, NULL)) {
pkg_emit_error("error reading public key(%s): %s", rsa_key_path,
ERR_error_string(ERR_get_error(), errbuf));
fclose(fp);
Expand Down
4 changes: 2 additions & 2 deletions pkg/query.c
Expand Up @@ -472,7 +472,7 @@ format_sql_condition(const char *str, struct sbuf *sqlcond)
/* only operators or space are allowed here */
if (isspace(str[0])) {
sbuf_putc(sqlcond, str[0]);
} else if (str[0] == '~' ) {
} else if (str[0] == '~') {
if (state != OPERATOR_STRING) {
fprintf(stderr, "~ expected only for string testing");
return (EPKG_FATAL);
Expand Down Expand Up @@ -546,7 +546,7 @@ format_sql_condition(const char *str, struct sbuf *sqlcond)
return (EPKG_FATAL);
}
sbuf_putc(sqlcond, str[0]);
} else if ( state == STRING ) {
} else if (state == STRING) {
if (isspace(str[0])) {
sbuf_putc(sqlcond, '"');
state = NONE;
Expand Down
2 changes: 1 addition & 1 deletion pkg/shlib.c
Expand Up @@ -98,7 +98,7 @@ exec_shlib(int argc, char **argv)
return (EX_IOERR);
}

while (( ret = pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC)) == EPKG_OK) {
while ((ret = pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC)) == EPKG_OK) {
if (count == 0)
printf("%s is linked to by the folowing packages:\n", libname);
count++;
Expand Down
2 changes: 1 addition & 1 deletion pkg/updating.c
Expand Up @@ -95,7 +95,7 @@ exec_updating(int argc, char **argv)

SLIST_INIT(&origins);
if (argc == 0) {
if (( it = pkgdb_query(db, NULL, MATCH_ALL)) == NULL)
if ((it = pkgdb_query(db, NULL, MATCH_ALL)) == NULL)
goto cleanup;

while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) == EPKG_OK) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/version.c
Expand Up @@ -350,7 +350,7 @@ exec_version(int argc, char **argv)
if (pkgdb_open(&db, PKGDB_DEFAULT) != EPKG_OK)
return (EX_IOERR);

if (( it = pkgdb_query(db, pattern, match)) == NULL)
if ((it = pkgdb_query(db, pattern, match)) == NULL)
goto cleanup;

while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) == EPKG_OK) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/which.c
Expand Up @@ -85,7 +85,7 @@ exec_which(int argc, char **argv)
return (EX_IOERR);
}

if (( ret = pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC)) == EPKG_OK) {
if ((ret = pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC)) == EPKG_OK) {
retcode = EPKG_OK;
pkg_get(pkg, PKG_NAME, &name, PKG_VERSION, &version, PKG_ORIGIN, &origin);
if (quiet && orig)
Expand Down

0 comments on commit 7aa1081

Please sign in to comment.