Skip to content

Commit

Permalink
Clear a few static analyzer warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
starseeker committed Jul 23, 2024
1 parent 7b4f444 commit b1995c4
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 26 deletions.
5 changes: 4 additions & 1 deletion src/conv/off/g-off.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,11 @@ main(int argc, char **argv)
*dot = '\0';
bu_strlcat(fig_file, ".fig", size); /* Add required Jack suffix. */

if ((fp_fig = fopen(fig_file, "wb")) == NULL)
if ((fp_fig = fopen(fig_file, "wb")) == NULL) {
perror(fig_file);
bu_exit(1, "ERROR: Unable to open %s\n", fig_file);
}

fprintf(fp_fig, "figure {\n");

/* Walk indicated tree(s). Each region will be output separately */
Expand Down
6 changes: 0 additions & 6 deletions src/libbv/polygon.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ bv_create_polygon_obj(struct bview *v, int flags, struct bv_polygon *p)
struct bv_scene_obj *
bv_create_polygon(struct bview *v, int flags, int type, point_t *fp)
{
bu_log("fp: %f %f %f\n", V3ARGS(*fp));

struct bv_polygon *p;
BU_GET(p, struct bv_polygon);
p->type = type;
Expand All @@ -225,7 +223,6 @@ bv_create_polygon(struct bview *v, int flags, int type, point_t *fp)

// This is now the origin point
VMOVE(p->origin_point, m_pt);
bu_log("origin_pt: %f %f %f\n", V3ARGS(m_pt));

int pcnt = 1;
if (type == BV_POLYGON_CIRCLE)
Expand Down Expand Up @@ -505,8 +502,6 @@ int
bv_update_polygon_circle(struct bv_scene_obj *s, point_t *cp, fastf_t pixel_size)
{
struct bv_polygon *p = (struct bv_polygon *)s->s_i_data;
bu_log("origin_pt: %f %f %f\n", V3ARGS(p->origin_point));
bu_log("cp: %f %f %f\n", V3ARGS(*cp));

fastf_t curr_fx, curr_fy;
fastf_t r, arc;
Expand All @@ -523,7 +518,6 @@ bv_update_polygon_circle(struct bv_scene_obj *s, point_t *cp, fastf_t pixel_size
bg_plane_pt_at(&pcp, &zpln, fx, fy);

r = DIST_PNT_PNT(pcp, p->origin_point);
bu_log("r: %f\n", r);

/* use a variable number of segments based on the size of the
* circle being created so small circles have few segments and
Expand Down
15 changes: 9 additions & 6 deletions src/librt/primitives/arb8/arb8.c
Original file line number Diff line number Diff line change
Expand Up @@ -1980,20 +1980,23 @@ rt_arb_calc_planes(struct bu_vls *error_msg_ret,
plane_t planes[6],
const struct bn_tol *tol)
{
register int i, p1, p2, p3;
int type = cgtype - ARB4; /* ARB4 at location 0, ARB5 at 1, etc. */
const int arb_faces[5][24] = rt_arb_faces;

/* ARB4 at location 0, ARB5 at 1, etc. */
int type = cgtype - ARB4;
if (type < 0 || type > 4)
return -1;

RT_ARB_CK_MAGIC(arb);
BN_CK_TOL(tol);

for (i = 0; i < 6; i++) {
for (int i = 0; i < 6; i++) {
if (arb_faces[type][i*4] == -1)
break; /* faces are done */

p1 = arb_faces[type][i*4];
p2 = arb_faces[type][i*4+1];
p3 = arb_faces[type][i*4+2];
int p1 = arb_faces[type][i*4];
int p2 = arb_faces[type][i*4+1];
int p3 = arb_faces[type][i*4+2];

if (bg_make_plane_3pnts(planes[i],
arb->pt[p1],
Expand Down
2 changes: 1 addition & 1 deletion src/librt/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ BRLCAD_ADDEXEC(db5_size db5_size.c "librt" TEST)
#BRLCAD_ADD_TEST(NAME rt_datum_basic COMMAND rt_datum)

# perturb testing
#BRLCAD_ADDEXEC(rt_perturb rt_perturb.c "librt;libwdb" TEST)
BRLCAD_ADDEXEC(rt_perturb rt_perturb.c "librt;libwdb" TEST)
#BRLCAD_ADD_TEST(NAME rt_perturb_basic COMMAND rt_perturb)

# cyclic path testing
Expand Down
22 changes: 10 additions & 12 deletions src/librt/tests/rt_perturb.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,12 @@ main(int UNUSED(argc), char *argv[])
struct rt_db_internal *ointern = NULL;
if (intern.idb_meth && intern.idb_meth->ft_perturb) {
intern.idb_meth->ft_perturb(&ointern, &intern, 0, 0, 2);
wdp = db_diradd(dbip, "rcc_perturb.s", RT_DIR_PHONY_ADDR, 0, RT_DIR_SOLID, (void *)&ointern->idb_type);
rt_db_put_internal(wdp, dbip, ointern, &rt_uniresource);
rt_db_free_internal(ointern);
BU_PUT(ointern, struct rt_db_internal);
db_update_nref(dbip, &rt_uniresource);
}

wdp = db_diradd(dbip, "rcc_perturb.s", RT_DIR_PHONY_ADDR, 0, RT_DIR_SOLID, (void *)&ointern->idb_type);
rt_db_put_internal(wdp, dbip, ointern, &rt_uniresource);
rt_db_free_internal(ointern);
BU_PUT(ointern, struct rt_db_internal);
db_update_nref(dbip, &rt_uniresource);
}

{
Expand Down Expand Up @@ -127,13 +126,12 @@ main(int UNUSED(argc), char *argv[])
struct rt_db_internal *ointern = NULL;
if (intern.idb_meth && intern.idb_meth->ft_perturb) {
intern.idb_meth->ft_perturb(&ointern, &intern, 0, 0, 100);
wdp = db_diradd(dbip, "arb_perturb.s", RT_DIR_PHONY_ADDR, 0, RT_DIR_SOLID, (void *)&ointern->idb_type);
rt_db_put_internal(wdp, dbip, ointern, &rt_uniresource);
rt_db_free_internal(ointern);
BU_PUT(ointern, struct rt_db_internal);
db_update_nref(dbip, &rt_uniresource);
}

wdp = db_diradd(dbip, "arb_perturb.s", RT_DIR_PHONY_ADDR, 0, RT_DIR_SOLID, (void *)&ointern->idb_type);
rt_db_put_internal(wdp, dbip, ointern, &rt_uniresource);
rt_db_free_internal(ointern);
BU_PUT(ointern, struct rt_db_internal);
db_update_nref(dbip, &rt_uniresource);
}

db_close(dbip);
Expand Down
7 changes: 7 additions & 0 deletions src/util/pix-ppm.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,17 @@ get_args(int argc, char *argv[], long *width, long *height)
fileinput++;
}

if (!infp)
bu_exit(0, "ERROR: infp is null\n");

if (isatty(fileno(infp))) {
bu_log("ERROR: %s will not read pix data from a tty\n", bu_getprogname());
return 0; /* usage */
}

if (!outfp)
bu_exit(0, "ERROR: outfp is null\n");

if (isatty(fileno(outfp))) {
bu_exit(0, "ERROR: %s will not write ppm data to a tty\n", bu_getprogname());
}
Expand Down

0 comments on commit b1995c4

Please sign in to comment.