From: Matthew Fernandez Date: Sun, 22 Nov 2020 05:51:02 +0000 (-0800) Subject: remove some unnecessary bracketing X-Git-Tag: 2.46.1~27^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc2a175bd911e9f03529cb84a9fadf914536f138;p=graphviz remove some unnecessary bracketing --- diff --git a/lib/cgraph/graph.c b/lib/cgraph/graph.c index d6eece37c..d695c6949 100644 --- a/lib/cgraph/graph.c +++ b/lib/cgraph/graph.c @@ -97,7 +97,7 @@ int agclose(Agraph_t * g) Agnode_t *n, *next_n; par = agparent(g); - if ((par == NILgraph) && (AGDISC(g, mem)->close)) { + if (par == NILgraph && AGDISC(g, mem)->close) { /* free entire heap */ agmethod_delete(g, g); /* invoke user callbacks */ agfreeid(g, AGRAPH, AGID(g)); diff --git a/lib/cgraph/rec.c b/lib/cgraph/rec.c index 0a51db4f5..61a3411f0 100644 --- a/lib/cgraph/rec.c +++ b/lib/cgraph/rec.c @@ -94,7 +94,7 @@ void *agbindrec(void *arg_obj, char *recname, unsigned int recsize, obj = arg_obj; g = agraphof(obj); rec = aggetrec(obj, recname, FALSE); - if ((rec == NIL(Agrec_t *)) && (recsize > 0)) { + if (rec == NIL(Agrec_t *) && recsize > 0) { rec = agalloc(g, recsize); rec->name = agstrdup(g, recname); objputrec(g, obj, rec); diff --git a/lib/fdpgen/clusteredges.c b/lib/fdpgen/clusteredges.c index 67d490d11..5323d8154 100644 --- a/lib/fdpgen/clusteredges.c +++ b/lib/fdpgen/clusteredges.c @@ -154,14 +154,13 @@ addGraphObjs(objlist * l, graph_t * g, void *tex, void *hex, expand_t* pm) int i; for (n = agfstnode(g); n; n = agnxtnode(g, n)) { - if ((PARENT(n) == g) && (n != tex) && (n != hex) - && !IS_CLUST_NODE(n)) { + if (PARENT(n) == g && n != tex && n != hex && !IS_CLUST_NODE(n)) { addObj(l, makeObstacle(n, pm, FALSE)); } } for (i = 1; i <= GD_n_cluster(g); i++) { sg = GD_clust(g)[i]; - if ((sg != tex) && (sg != hex)) { + if (sg != tex && sg != hex) { addObj(l, makeClustObs(sg, pm)); } } @@ -266,7 +265,7 @@ int compoundEdges(graph_t * g, expand_t* pm, int edgetype) for (n = agfstnode(g); n; n = agnxtnode(g, n)) { for (e = agfstout(g, n); e; e = agnxtout(g, e)) { head = aghead(e); - if ((n == head) && ED_count(e)) { /* self arc */ + if (n == head && ED_count(e)) { /* self arc */ if (!P) { P = NEW(path); P->boxes = N_NEW(agnnodes(g) + 20 * 2 * 9, boxf); @@ -287,9 +286,9 @@ int compoundEdges(graph_t * g, expand_t* pm, int edgetype) expand_t margin = sepFactor(g); int pack = getPack (g, CL_OFFSET, CL_OFFSET); agerr(AGWARN, "compoundEdges: nodes touch - falling back to straight line edges\n"); - if ((pack <= pm->x) || (pack <= pm->y)) + if (pack <= pm->x || pack <= pm->y) agerr(AGPREV, "pack value %d is smaller than esep (%.03f,%.03f)\n", pack, pm->x, pm->y); - else if ((margin.x <= pm->x) || (margin.y <= pm->y)) + else if (margin.x <= pm->x || margin.y <= pm->y) agerr(AGPREV, "sep value (%.03f,%.03f) is smaller than esep (%.03f,%.03f)\n", margin.x, margin.y, pm->x, pm->y); rv = 1; diff --git a/lib/fdpgen/dbg.c b/lib/fdpgen/dbg.c index 4460b664c..c294a9462 100644 --- a/lib/fdpgen/dbg.c +++ b/lib/fdpgen/dbg.c @@ -320,8 +320,7 @@ static void pswrite(Agraph_t * g, FILE * fp, int expMode) /* Check for rotation */ - if ((p = agget(g, "rotate")) && (*p != '\0') - && ((angle = atoi(p)) != 0)) { + if ((p = agget(g, "rotate")) && *p != '\0' && (angle = atoi(p)) != 0) { fprintf(fp, "306 396 translate\n"); fprintf(fp, "%d rotate\n", angle); fprintf(fp, "-306 -396 translate\n"); @@ -338,9 +337,9 @@ static void pswrite(Agraph_t * g, FILE * fp, int expMode) if (width > PSWidth) { if (height > PSHeight) { scale = - (PSWidth / width < + PSWidth / width < PSHeight / height ? PSWidth / width : PSHeight / - height); + height; } else scale = PSWidth / width; } else if (height > PSHeight) { diff --git a/lib/fdpgen/fdpinit.c b/lib/fdpgen/fdpinit.c index b18faff01..b272dc650 100644 --- a/lib/fdpgen/fdpinit.c +++ b/lib/fdpgen/fdpinit.c @@ -51,7 +51,7 @@ static void initialPositions(graph_t * g) pvec[j] = pvec[j] / PSinputscale; } ND_pinned(np) = P_SET; - if ((c == '!') + if (c == '!' || (pinsym && mapbool(agxget(np, pinsym)))) ND_pinned(np) = P_PIN; } else diff --git a/lib/fdpgen/grid.c b/lib/fdpgen/grid.c index 06612f8e3..f99c0136e 100644 --- a/lib/fdpgen/grid.c +++ b/lib/fdpgen/grid.c @@ -100,10 +100,10 @@ static int ijcmpf(Dt_t * d, gridpt * p1, gridpt * p2, Dtdisc_t * disc) NOTUSED(d); NOTUSED(disc); - if ((diff = (p1->i - p2->i))) + if ((diff = p1->i - p2->i)) return diff; else - return (p1->j - p2->j); + return p1->j - p2->j; } static Grid *_grid; /* hack because can't attach info. to Dt_t */ @@ -184,7 +184,7 @@ void adjustGrid(Grid * g, int nnodes) int nsize; if (nnodes > g->listSize) { - nsize = MAX(nnodes, 2 * (g->listSize)); + nsize = MAX(nnodes, 2 * g->listSize); if (g->listMem) free(g->listMem); g->listMem = N_GNEW(nsize, node_list); @@ -255,7 +255,7 @@ cell *findGrid(Grid * g, int i, int j) key.p.i = i; key.p.j = j; - return ((cell *) dtsearch(g->data, &key)); + return (cell *) dtsearch(g->data, &key); } /* gLength: diff --git a/lib/fdpgen/layout.c b/lib/fdpgen/layout.c index cdf494acb..d52372949 100644 --- a/lib/fdpgen/layout.c +++ b/lib/fdpgen/layout.c @@ -85,7 +85,7 @@ finalCC(graph_t * g, int c_cnt, graph_t ** cc, point * pts, graph_t * rg, int margin; graph_t **cp = cc; point *pp = pts; - int isRoot = (rg == infop->rootg); + int isRoot = rg == infop->rootg; int isEmpty = 0; /* compute graph bounding box in points */ @@ -349,7 +349,7 @@ static void chkPos(graph_t* g, node_t* n, layout_info* infop, boxf* bbp) if (g != infop->rootg) { parent =agparent(g); pp = agxget(parent, G_coord); - if ((pp == p) || !strcmp(p, pp)) + if (pp == p || !strcmp(p, pp)) return; } c = '\0'; @@ -482,7 +482,7 @@ static graph_t *deriveGraph(graph_t * g, layout_info * infop) /* create derived nodes from remaining nodes */ for (n = agfstnode(g); n; n = agnxtnode(g, n)) { if (!DNODE(n)) { - if (PARENT(n) && (PARENT(n) != GPARENT(g))) { + if (PARENT(n) && PARENT(n) != GPARENT(g)) { agerr (AGERR, "node \"%s\" is contained in two non-comparable clusters \"%s\" and \"%s\"\n", agnameof(n), agnameof(g), agnameof(PARENT(n))); longjmp (jbuf, 1); } @@ -638,7 +638,7 @@ static erec *getEdgeList(node_t * n, graph_t * g) while (i < deg - 1) { a = erecs[i].alpha; j = i + 1; - while ((j < deg) && (erecs[j].alpha == a)) + while (j < deg && erecs[j].alpha == a) j++; if (j == i + 1) i = j; @@ -707,7 +707,7 @@ genPorts(node_t * n, erec * er, bport_t * pp, int idx, double bnd) for (j = 0; j < ED_count(e); j++, ep++) { el = *ep; pp[i].e = el; - pp[i].n = (DNODE(agtail(el)) == n ? agtail(el) : aghead(el)); + pp[i].n = DNODE(agtail(el)) == n ? agtail(el) : aghead(el); pp[i].alpha = angle; i += inc; angle += delta; @@ -1001,7 +1001,7 @@ static void init_info(graph_t * g, layout_info * infop) infop->G_height = agattr(g, AGRAPH, "height", NULL); infop->rootg = g; infop->gid = 0; - infop->pack.mode = getPackInfo(g, l_node, CL_OFFSET / 2, &(infop->pack)); + infop->pack.mode = getPackInfo(g, l_node, CL_OFFSET / 2, &infop->pack); } /* mkClusters: @@ -1088,7 +1088,7 @@ fdpSplines (graph_t * g) if (trySplines) Nop = 2; } - if (trySplines || (et != ET_COMPOUND)) { + if (trySplines || et != ET_COMPOUND) { if (HAS_CLUST_EDGE(g)) { agerr(AGWARN, "splines and cluster edges not supported - using line segments\n"); diff --git a/lib/fdpgen/tlayout.c b/lib/fdpgen/tlayout.c index be8deea45..d00895900 100644 --- a/lib/fdpgen/tlayout.c +++ b/lib/fdpgen/tlayout.c @@ -120,7 +120,7 @@ static parms_t parms; static double cool(double temp, int t) { - return (T_T0 * (T_maxIters - t)) / T_maxIters; + return T_T0 * (T_maxIters - t) / T_maxIters; } /* reset_params: @@ -200,7 +200,7 @@ void fdp_initParams(graph_t * g) T_seed = DFLT_smode; } - T_pass1 = (T_unscaled * T_maxIters) / 100; + T_pass1 = T_unscaled * T_maxIters / 100; T_K2 = T_K * T_K; if (T_useGrid) { @@ -342,9 +342,9 @@ static void applyAttr(Agnode_t * p, Agnode_t * q, Agedge_t * e) } dist = sqrt(dist2); if (T_useNew) - force = (ED_factor(e) * (dist - ED_dist(e))) / dist; + force = ED_factor(e) * (dist - ED_dist(e)) / dist; else - force = (ED_factor(e) * dist) / ED_dist(e); + force = ED_factor(e) * dist / ED_dist(e); DISP(q)[0] -= xdelta * force; DISP(q)[1] -= ydelta * force; DISP(p)[0] += xdelta * force; @@ -372,14 +372,14 @@ static void updatePos(Agraph_t * g, double temp, bport_t * pp) x = ND_pos(n)[0] + dx; y = ND_pos(n)[1] + dy; } else { - double fact = temp / (sqrt(len2)); + double fact = temp / sqrt(len2); x = ND_pos(n)[0] + dx * fact; y = ND_pos(n)[1] + dy * fact; } /* if ports, limit by boundary */ if (pp) { - d = sqrt((x * x) / T_Wd2 + (y * y) / T_Ht2); + d = sqrt(x * x / T_Wd2 + y * y / T_Ht2); if (IS_PORT(n)) { ND_pos(n)[0] = x / d; ND_pos(n)[1] = y / d; @@ -500,7 +500,7 @@ static pointf initPositions(graph_t * g, bport_t * pp) width = EXPFACTOR * (bb.UR.x - bb.LL.x); height = EXPFACTOR * (bb.UR.y - bb.LL.y); area = 4.0 * T_Wd * T_Ht; - quot = (width * height) / area; + quot = width * height / area; if (quot >= 1.0) { /* If bbox has large enough area, use it */ T_Wd = width / 2.0; T_Ht = height / 2.0; @@ -578,7 +578,7 @@ static pointf initPositions(graph_t * g, bport_t * pp) for (ep = agfstedge(g, np); ep; ep = agnxtedge(g, ep, np)) { if (aghead(ep) == agtail(ep)) continue; - op = (aghead(ep) == np ? agtail(ep) : aghead(ep)); + op = aghead(ep) == np ? agtail(ep) : aghead(ep); if (!hasPos(op)) continue; if (cnt) { @@ -691,7 +691,7 @@ void fdp_tLayout(graph_t * g, xparams * xpms) } } - if ((ctr.x != 0.0) || (ctr.y != 0.0)) { + if (ctr.x != 0.0 || ctr.y != 0.0) { for (n = agfstnode(g); n; n = agnxtnode(g, n)) { ND_pos(n)[0] += ctr.x; ND_pos(n)[1] += ctr.y; diff --git a/lib/fdpgen/xlayout.c b/lib/fdpgen/xlayout.c index 1348b48dc..cc1c7d12f 100644 --- a/lib/fdpgen/xlayout.c +++ b/lib/fdpgen/xlayout.c @@ -105,7 +105,7 @@ static void xinit_params(graph_t* g, int n, xparams * xpms) static double cool(int t) { - return (X_T0 * (X_numIters - t)) / X_numIters; + return X_T0 * (X_numIters - t) / X_numIters; } #define EPSILON 0.01 @@ -120,7 +120,7 @@ static double dist(pointf p, pointf q) dx = p.x - q.x; dy = p.y - q.y; - return (sqrt(dx * dx + dy * dy)); + return sqrt(dx * dx + dy * dy); } /* bBox: @@ -150,54 +150,54 @@ static double boxDist(node_t * p, node_t * q) if (q_ll.x > p_ur.x) { if (q_ll.y > p_ur.y) { - return (dist(p_ur, q_ll)); + return dist(p_ur, q_ll); } else if (q_ll.y >= p_ll.y) { - return (q_ll.x - p_ur.x); + return q_ll.x - p_ur.x; } else { if (q_ur.y >= p_ll.y) - return (q_ll.x - p_ur.x); + return q_ll.x - p_ur.x; else { p_ur.y = p_ll.y; /* p_ur is now lower right */ q_ll.y = q_ur.y; /* q_ll is now upper left */ - return (dist(p_ur, q_ll)); + return dist(p_ur, q_ll); } } } else if (q_ll.x >= p_ll.x) { if (q_ll.y > p_ur.y) { - return (q_ll.y - p_ur.x); + return q_ll.y - p_ur.x; } else if (q_ll.y >= p_ll.y) { return 0.0; } else { if (q_ur.y >= p_ll.y) return 0.0; else - return (p_ll.y - q_ur.y); + return p_ll.y - q_ur.y; } } else { if (q_ll.y > p_ur.y) { if (q_ur.x >= p_ll.x) - return (q_ll.y - p_ur.y); + return q_ll.y - p_ur.y; else { p_ur.x = p_ll.x; /* p_ur is now upper left */ q_ll.x = q_ur.x; /* q_ll is now lower right */ - return (dist(p_ur, q_ll)); + return dist(p_ur, q_ll); } } else if (q_ll.y >= p_ll.y) { if (q_ur.x >= p_ll.x) return 0.0; else - return (p_ll.x - q_ur.x); + return p_ll.x - q_ur.x; } else { if (q_ur.x >= p_ll.x) { if (q_ur.y >= p_ll.y) return 0.0; else - return (p_ll.y - q_ur.y); + return p_ll.y - q_ur.y; } else { if (q_ur.y >= p_ll.y) - return (p_ll.x - q_ur.x); + return p_ll.x - q_ur.x; else - return (dist(p_ll, q_ur)); + return dist(p_ll, q_ur); } } } @@ -219,7 +219,7 @@ static int overlap(node_t * p, node_t * q) ydelta = ND_pos(q)[1] - ND_pos(p)[1]; if (ydelta < 0) ydelta = -ydelta; - ret = ((xdelta <= (WD2(p) + WD2(q))) && (ydelta <= (HT2(p) + HT2(q)))); + ret = xdelta <= WD2(p) + WD2(q) && ydelta <= HT2(p) + HT2(q); return ret; #else double dist2, xdelta, ydelta; @@ -229,7 +229,7 @@ static int overlap(node_t * p, node_t * q) xdelta = ND_pos(q)[0] - ND_pos(p)[0]; ydelta = ND_pos(q)[1] - ND_pos(p)[1]; dist2 = xdelta * xdelta + ydelta * ydelta; - return (dist2 <= (din * din)); + return dist2 <= din * din; #endif } @@ -350,7 +350,7 @@ static void applyAttr(Agnode_t * p, Agnode_t * q) if (dist < X_K + din) return; dout = dist - din; - force = (dout * dout) / ((X_K + din) * dist); + force = dout * dout / ((X_K + din) * dist); #else if (overlap(p, q)) { #ifdef DEBUG @@ -366,7 +366,7 @@ static void applyAttr(Agnode_t * p, Agnode_t * q) dist = sqrt(xdelta * xdelta + ydelta * ydelta); din = RAD(p) + RAD(q); dout = dist - din; - force = (dout * dout) / ((X_K + din) * dist); + force = dout * dout / ((X_K + din) * dist); #endif #ifdef DEBUG if (Verbose == 4) { @@ -433,8 +433,8 @@ static int adjust(Agraph_t * g, double temp) } else { /* to avoid sqrt, consider abs(x) + abs(y) */ len = sqrt(len2); - ND_pos(n)[0] += (disp[0] * temp) / len; - ND_pos(n)[1] += (disp[1] * temp) / len; + ND_pos(n)[0] += disp[0] * temp / len; + ND_pos(n)[1] += disp[1] * temp / len; } } return overlaps; @@ -475,10 +475,10 @@ static int x_layout(graph_t * g, xparams * pxpms, int tries) try = 0; xpms = *pxpms; K = xpms.K; - while (ov && (try < tries)) { + while (ov && try < tries) { xinit_params(g, nnodes, &xpms); X_ov = X_C * K2; - X_nonov = (nedges*X_ov*2.0)/(nnodes*(nnodes-1)); + X_nonov = nedges*X_ov*2.0/(nnodes*(nnodes-1)); #ifdef DEBUG if (Verbose) { prIndent(); @@ -535,11 +535,11 @@ void fdp_xLayout(graph_t * g, xparams * xpms) #endif fprintf (stderr, "xLayout "); } - if (!ovlp || (*ovlp == '\0')) { + if (!ovlp || *ovlp == '\0') { ovlp = DFLT_overlap; } /* look for optional ":" or "number:" */ - if ((cp = strchr(ovlp, ':')) && ((cp == ovlp) || isdigit(*ovlp))) { + if ((cp = strchr(ovlp, ':')) && (cp == ovlp || isdigit(*ovlp))) { cp++; rest = cp; tries = atoi (ovlp);