]> granicus.if.org Git - graphviz/log
graphviz
2 years agosmyrna attr_list_add: fix unchecked allocation failure
Matthew Fernandez [Fri, 2 Sep 2022 01:30:01 +0000 (18:30 -0700)]
smyrna attr_list_add: fix unchecked allocation failure

2 years agosmyrna attr_list_new: fix unchecked allocation failures
Matthew Fernandez [Fri, 2 Sep 2022 01:29:37 +0000 (18:29 -0700)]
smyrna attr_list_new: fix unchecked allocation failures

2 years agosmyrna new_attr_ref: fix unchecked allocation failure
Matthew Fernandez [Fri, 2 Sep 2022 01:29:13 +0000 (18:29 -0700)]
smyrna new_attr_ref: fix unchecked allocation failure

2 years agosmyrna new_attr: fix unchecked allocation failure
Matthew Fernandez [Fri, 2 Sep 2022 01:28:56 +0000 (18:28 -0700)]
smyrna new_attr: fix unchecked allocation failure

2 years agosmyrna create_color_theme: use cgraph wrapper for allocations
Matthew Fernandez [Fri, 2 Sep 2022 01:17:10 +0000 (18:17 -0700)]
smyrna create_color_theme: use cgraph wrapper for allocations

The lib/cgraph/alloc.h wrappers are similar to the older lib/common/memory.h
wrappers except (1) they are header-only and (2) they live in a directory
(cgraph) that is at the root of the dependency tree. The long term plan is to
replace all use of lib/common/memory.h with lib/cgraph/alloc.h.

2 years agosmyrna init_viewport: use cgraph wrapper for allocations
Matthew Fernandez [Fri, 2 Sep 2022 01:14:51 +0000 (18:14 -0700)]
smyrna init_viewport: use cgraph wrapper for allocations

The lib/cgraph/alloc.h wrappers are similar to the older lib/common/memory.h
wrappers except (1) they are header-only and (2) they live in a directory
(cgraph) that is at the root of the dependency tree. The long term plan is to
replace all use of lib/common/memory.h with lib/cgraph/alloc.h.

2 years agosmyrna add_graph_to_viewport: fix unchecked allocation failure
Matthew Fernandez [Fri, 2 Sep 2022 01:14:05 +0000 (18:14 -0700)]
smyrna add_graph_to_viewport: fix unchecked allocation failure

2 years agosmyrna load_mouse_actions: fix unchecked allocation failure
Matthew Fernandez [Fri, 2 Sep 2022 01:12:22 +0000 (18:12 -0700)]
smyrna load_mouse_actions: fix unchecked allocation failure

2 years agosmyrna add_selpoly: fix unchecked allocation failure
Matthew Fernandez [Fri, 2 Sep 2022 01:02:37 +0000 (18:02 -0700)]
smyrna add_selpoly: fix unchecked allocation failure

2 years agosmyrna clear_selpoly: simplify some 'free' code
Matthew Fernandez [Fri, 2 Sep 2022 01:01:04 +0000 (18:01 -0700)]
smyrna clear_selpoly: simplify some 'free' code

2 years agosmyrna Render_Contour2: fix unchecked allocation failure
Matthew Fernandez [Fri, 2 Sep 2022 00:59:12 +0000 (17:59 -0700)]
smyrna Render_Contour2: fix unchecked allocation failure

2 years agosmyrna combineCallback: fix unchecked allocation failure
Matthew Fernandez [Fri, 2 Sep 2022 00:58:17 +0000 (17:58 -0700)]
smyrna combineCallback: fix unchecked allocation failure

2 years agosmyrna clearGrid: use cgraph wrapper for allocation
Matthew Fernandez [Fri, 2 Sep 2022 00:48:55 +0000 (17:48 -0700)]
smyrna clearGrid: use cgraph wrapper for allocation

The lib/cgraph/alloc.h wrappers are similar to the older lib/common/memory.h
wrappers except (1) they are header-only and (2) they live in a directory
(cgraph) that is at the root of the dependency tree. The long term plan is to
replace all use of lib/common/memory.h with lib/cgraph/alloc.h.

2 years agosmyrna update_tree: use cgraph wrapper for allocation
Matthew Fernandez [Fri, 2 Sep 2022 00:53:09 +0000 (17:53 -0700)]
smyrna update_tree: use cgraph wrapper for allocation

The lib/cgraph/alloc.h wrappers are similar to the older lib/common/memory.h
wrappers except (1) they are header-only and (2) they live in a directory
(cgraph) that is at the root of the dependency tree. The long term plan is to
replace all use of lib/common/memory.h with lib/cgraph/alloc.h.

2 years agosmyrna add_column: use cgraph wrapper for allocation
Matthew Fernandez [Fri, 2 Sep 2022 00:47:46 +0000 (17:47 -0700)]
smyrna add_column: use cgraph wrapper for allocation

The lib/cgraph/alloc.h wrappers are similar to the older lib/common/memory.h
wrappers except (1) they are header-only and (2) they live in a directory
(cgraph) that is at the root of the dependency tree. The long term plan is to
replace all use of lib/common/memory.h with lib/cgraph/alloc.h.

2 years agosmyrna add_column: fix unchecked allocation failure
Matthew Fernandez [Fri, 2 Sep 2022 00:46:47 +0000 (17:46 -0700)]
smyrna add_column: fix unchecked allocation failure

2 years agoMerge branch 'smattr/8ef08678-9ef1-4024-90bf-ffca3cd5dbaa' into 'main'
Matthew Fernandez [Wed, 31 Aug 2022 01:45:09 +0000 (01:45 +0000)]
Merge branch 'smattr/8ef08678-9ef1-4024-90bf-ffca3cd5dbaa' into 'main'

sfdpgen cgraph/alloc.h migration, clean up, fixing incorrect 'MAX' calls

Closes #2269

See merge request graphviz/graphviz!2819

2 years agosparse SparseMatrix_coordinate_form_add_entry: abbreviate no-op 'MAX' call
Matthew Fernandez [Sun, 28 Aug 2022 20:23:01 +0000 (13:23 -0700)]
sparse SparseMatrix_coordinate_form_add_entry: abbreviate no-op 'MAX' call

d1d1ae30865c14bb7e6a75f8772543c10419e48b seems to have incorrectly assumed
multiplication has a higher precedence than casts. In reality, it is the
opposite, meaning the first parameter to this `MAX` call was always 0. So the
entire expression would evaluate to 10. Empirically this seems to have been fine
since this code has been in use for over a decade with no specific problems
blamed on this area. So lets just abbreviate it into what it evaluates to.

Gitlab: fixes #2269

2 years agosparse check_or_realloc_arrays: abbreviate no-op 'MAX' call
Matthew Fernandez [Sun, 28 Aug 2022 20:21:18 +0000 (13:21 -0700)]
sparse check_or_realloc_arrays: abbreviate no-op 'MAX' call

1b847b5abf50d2ab0701523b90a20306d0ee5528 seems to have incorrectly assumed
multiplication has a higher precedence than casts. In reality, it is the
opposite, meaning the first parameter to this `MAX` call was always 0. So the
entire expression would evaluate to 10. Empirically this seems to have been fine
since this code has been in use for over a decade with no specific problems
blamed on this area. So lets just abbreviate it into what it evaluates to.

Gitlab: #2269

2 years agoneatogen stress_majorization_with_hierarchy: abbreviate a double literal
Matthew Fernandez [Sun, 28 Aug 2022 20:20:47 +0000 (13:20 -0700)]
neatogen stress_majorization_with_hierarchy: abbreviate a double literal

2 years agogvmap add_point: abbreviate no-op 'MAX' call
Matthew Fernandez [Sun, 28 Aug 2022 20:19:54 +0000 (13:19 -0700)]
gvmap add_point: abbreviate no-op 'MAX' call

c193a91a0e9d8565e85bd6953a2c64e971d6ab79 seems to have incorrectly assumed
multiplication has a higher precedence than casts. In reality, it is the
opposite, meaning the first parameter to this `MAX` call was always 0. So the
entire expression would evaluate to 20. Empirically this seems to have been fine
since this code has been in use for over a decade with no specific problems
blamed on this area. So lets just abbreviate it into what it evaluates to.

Gitlab: #2269

2 years agosfdpgen check_int_array_size: abbreviate no-op 'MAX' call
Matthew Fernandez [Sun, 28 Aug 2022 20:14:16 +0000 (13:14 -0700)]
sfdpgen check_int_array_size: abbreviate no-op 'MAX' call

1b847b5abf50d2ab0701523b90a20306d0ee5528 seems to have incorrectly assumed
multiplication has a higher precedence than casts. In reality, it is the
opposite, meaning the first parameter to this `MAX` call was always 0. So the
entire expression would evaluate to 10. Empirically this seems to have been fine
since this code has been in use for over a decade with no specific problems
blamed on this area. So lets just abbreviate it into what it evaluates to.

Gitlab: #2269

2 years agosfdpgen check_real_array_size: abbreviate no-op 'MAX' call
Matthew Fernandez [Sun, 28 Aug 2022 20:11:26 +0000 (13:11 -0700)]
sfdpgen check_real_array_size: abbreviate no-op 'MAX' call

1b847b5abf50d2ab0701523b90a20306d0ee5528 seems to have incorrectly assumed
multiplication has a higher precedence than casts. In reality, it is the
opposite, meaning the first parameter to this `MAX` call was always 0. So the
entire expression would evaluate to 10. Empirically this seems to have been fine
since this code has been in use for over a decade with no specific problems
blamed on this area. So lets just abbreviate it into what it evaluates to.

Gitlab: #2269

2 years agosfdpgen beautify_leaves: use cgraph wrappers for allocation
Matthew Fernandez [Sun, 28 Aug 2022 20:09:30 +0000 (13:09 -0700)]
sfdpgen beautify_leaves: use cgraph wrappers for allocation

The lib/cgraph/alloc.h wrappers are similar to the older lib/common/memory.h
wrappers except (1) they are header-only and (2) they live in a directory
(cgraph) that is at the root of the dependency tree. The long term plan is to
replace all use of lib/common/memory.h with lib/cgraph/alloc.h.

2 years agosfdpgen oned_optimizer_new: use cgraph wrapper for allocation
Matthew Fernandez [Sun, 28 Aug 2022 19:54:16 +0000 (12:54 -0700)]
sfdpgen oned_optimizer_new: use cgraph wrapper for allocation

The lib/cgraph/alloc.h wrappers are similar to the older lib/common/memory.h
wrappers except (1) they are header-only and (2) they live in a directory
(cgraph) that is at the root of the dependency tree. The long term plan is to
replace all use of lib/common/memory.h with lib/cgraph/alloc.h.

2 years agosfdpgen spring_electrical_control: remove 'multilevel_coarsen_mode'
Matthew Fernandez [Sun, 28 Aug 2022 19:52:10 +0000 (12:52 -0700)]
sfdpgen spring_electrical_control: remove 'multilevel_coarsen_mode'

This was never set to anything other than `COARSEN_MODE_FORCEFUL`.

2 years agosfdpgen spring_electrical_control: remove 'multilevel_coarsen_scheme'
Matthew Fernandez [Sun, 28 Aug 2022 19:39:55 +0000 (12:39 -0700)]
sfdpgen spring_electrical_control: remove 'multilevel_coarsen_scheme'

This was never set to anything other than
`COARSEN_INDEPENDENT_EDGE_SET_HEAVEST_EDGE_PERNODE_SUPERNODES_FIRST`.

2 years agosfdpgen spring_electrical_control_new: use cgraph wrapper for allocation
Matthew Fernandez [Sun, 28 Aug 2022 19:33:02 +0000 (12:33 -0700)]
sfdpgen spring_electrical_control_new: use cgraph wrapper for allocation

The lib/cgraph/alloc.h wrappers are similar to the older lib/common/memory.h
wrappers except (1) they are header-only and (2) they live in a directory
(cgraph) that is at the root of the dependency tree. The long term plan is to
replace all use of lib/common/memory.h with lib/cgraph/alloc.h.

2 years agosfdpgen beautify_leaves: swap a boolean array for a bit array
Matthew Fernandez [Sun, 28 Aug 2022 19:25:23 +0000 (12:25 -0700)]
sfdpgen beautify_leaves: swap a boolean array for a bit array

This reduces memory pressure by using 1-bit per element instead of 1-byte per
element. Unfortunately this introduces 4 -Wsign-conversion warnings due to
indexing in this function being done with signed variables. But the change still
seems like an improvement on the existing code.

2 years agoMerge branch 'minor-cleanup-of-svg-analyzer' into 'main'
Magnus Jacobsson [Tue, 30 Aug 2022 21:12:13 +0000 (21:12 +0000)]
Merge branch 'minor-cleanup-of-svg-analyzer' into 'main'

Minor cleanup of the SVG analyzer

See merge request graphviz/graphviz!2810

2 years agotests: SVGAnalyzer: use fmt::format instead of string concatenation
Magnus Jacobsson [Wed, 24 Aug 2022 11:00:56 +0000 (13:00 +0200)]
tests: SVGAnalyzer: use fmt::format instead of string concatenation

2 years agotests: SVGAnalyzer: correct comment
Magnus Jacobsson [Wed, 24 Aug 2022 11:00:30 +0000 (13:00 +0200)]
tests: SVGAnalyzer: correct comment

2 years agotests: SVGAnalyzer: avoid string copy by taking reference instead
Magnus Jacobsson [Wed, 24 Aug 2022 11:00:07 +0000 (13:00 +0200)]
tests: SVGAnalyzer: avoid string copy by taking reference instead

2 years agotests: test_svg_analyzer: remove useless string copy
Magnus Jacobsson [Wed, 17 Aug 2022 18:30:26 +0000 (20:30 +0200)]
tests: test_svg_analyzer: remove useless string copy

Despite its name, 'shape_char_ptr' was already a std::string.

2 years agotests: test_svg_analyzer: Update test description
Magnus Jacobsson [Sat, 20 Aug 2022 21:11:10 +0000 (23:11 +0200)]
tests: test_svg_analyzer: Update test description

2 years agotests: test_svg_analyzer: remove useless include of graphviz_graph.h
Magnus Jacobsson [Fri, 26 Aug 2022 11:19:08 +0000 (13:19 +0200)]
tests: test_svg_analyzer: remove useless include of graphviz_graph.h

2 years agotests: rename variables '.*svgAnalyzer' to '.*svg_analyzer'
Magnus Jacobsson [Sat, 20 Aug 2022 21:16:06 +0000 (23:16 +0200)]
tests: rename variables '.*svgAnalyzer' to '.*svg_analyzer'

Almost no other variables use camel case.

2 years agotests: SVGAnalyzer: add some comments
Magnus Jacobsson [Tue, 23 Aug 2022 15:18:17 +0000 (17:18 +0200)]
tests: SVGAnalyzer: add some comments

2 years agotests: SVGAnalyzer: use fmt::format instead of string concatenation
Magnus Jacobsson [Tue, 23 Aug 2022 15:20:50 +0000 (17:20 +0200)]
tests: SVGAnalyzer: use fmt::format instead of string concatenation

2 years agotests: test_rankdir: remove useless generation of copy
Magnus Jacobsson [Tue, 23 Aug 2022 19:09:44 +0000 (21:09 +0200)]
tests: test_rankdir: remove useless generation of copy

The generator expression will not outlive the scope of
'node_shapes_without_svg_shape' or 'all_node_shapes' which both live
in the global scope, so copying is unnecessary.

For details, see
https://github.com/catchorg/Catch2/blob/devel/docs/generators.md#provided-generators.

2 years agoMerge branch 'smattr/cc0c1b4c-ccdf-48a9-adc6-8c301067068a' into 'main'
Matthew Fernandez [Tue, 30 Aug 2022 15:51:20 +0000 (15:51 +0000)]
Merge branch 'smattr/cc0c1b4c-ccdf-48a9-adc6-8c301067068a' into 'main'

gvpr: fix: wrap members needing cleanup in a struct and outline

Closes #1801

See merge request graphviz/graphviz!2817

2 years agogvpr: more tightly scope 'nextg'
Matthew Fernandez [Sun, 28 Aug 2022 03:18:07 +0000 (20:18 -0700)]
gvpr: more tightly scope 'nextg'

This squashes a -Wclobbered compiler warning. Though, as discussed in the prior
commit, I believe this to be a false positive.

As of this commit, Graphviz builds free of -Wclobbered warnings.

Gitlab: closes #1801

2 years agogvpr: fix: wrap members needing cleanup in a struct and outline
Matthew Fernandez [Sun, 28 Aug 2022 03:04:07 +0000 (20:04 -0700)]
gvpr: fix: wrap members needing cleanup in a struct and outline

When seeing this code, the compiler emitted numerous warnings like:

  gvpr.c: In function ‘gvpr’:
  gvpr.c:929:17: warning: variable ‘prog’ might be clobbered by
    ‘longjmp’ or ‘vfork’ [-Wclobbered]
       parse_prog *prog = 0;
                   ^~~~

What it is trying to tell us is that this code violates the assumptions of
`setjmp`/`longjmp`. Referencing any non-volatile stack-allocated variable after
a `longjmp` is undefined behavior.¹

This change extracts all the members that need to be referenced after `longjmp`
into a wrapper function. This basically puts a function call boundary in a place
such that the code no longer violates assumptions of the C standard. It is a
little awkward that we have to do this by hand, as the transformation is
mechanical and the compiler technically has enough information to do this for
us. But `setjmp`/`longjmp` come from the old world and are low level mechanisms.
If the compiler sees a call to them, it assumes you are doing something unusual
and want to do it exactly as you wrote.

While making this adjustment, some white space is adjusted and some coercion to
boolean is changed to explicit comparisons against `NULL`.

I do not understand why, but after this change the compiler still believes
`nextg` can be clobbered by a `longjmp`. While this is true, `nextg` is not used
after `longjmp`-ing back to `gvpr_core`, so I do not know why the compiler
thinks it needs to warn us about this.

Gitlab: #1801

¹ This restriction stems from how `setjmp`/`longjmp` work on certain platforms.
  If a variable is live in a register instead of on the stack, it is not
  guaranteed to be restored during a `longjmp`. Hence why the value of such
  variables is undefined after a `longjmp`.

2 years agoMerge branch 'smattr/bdd2e8b6-9a48-4e33-815d-2c049a7ca7f2' into 'main'
Matthew Fernandez [Tue, 30 Aug 2022 14:52:56 +0000 (14:52 +0000)]
Merge branch 'smattr/bdd2e8b6-9a48-4e33-815d-2c049a7ca7f2' into 'main'

cmd/tools: use cgraph wrappers for allocation

See merge request graphviz/graphviz!2818

2 years agogml2gv gmlparse: fix unchecked allocation failures
Matthew Fernandez [Sun, 28 Aug 2022 16:10:32 +0000 (09:10 -0700)]
gml2gv gmlparse: fix unchecked allocation failures

2 years agogml2gv gmlscan: fix unchecked allocation failures
Matthew Fernandez [Sun, 28 Aug 2022 16:09:10 +0000 (09:09 -0700)]
gml2gv gmlscan: fix unchecked allocation failures

2 years agodijkstra init: fix unchecked allocation failure
Matthew Fernandez [Sun, 28 Aug 2022 16:08:00 +0000 (09:08 -0700)]
dijkstra init: fix unchecked allocation failure

2 years agogvcolor color: fix unchecked allocation failure
Matthew Fernandez [Sun, 28 Aug 2022 16:04:12 +0000 (09:04 -0700)]
gvcolor color: fix unchecked allocation failure

2 years agogxl2gv endElementHandler: use cgraph wrapper for allocation
Matthew Fernandez [Sun, 28 Aug 2022 15:59:58 +0000 (08:59 -0700)]
gxl2gv endElementHandler: use cgraph wrapper for allocation

The lib/cgraph/alloc.h wrappers are similar to the older lib/common/memory.h
wrappers except (1) they are header-only and (2) they live in a directory
(cgraph) that is at the root of the dependency tree. The long term plan is to
replace all use of lib/common/memory.h with lib/cgraph/alloc.h.

2 years agogml2gv mkAttr: fix unchecked allocation failures
Matthew Fernandez [Sun, 28 Aug 2022 15:52:50 +0000 (08:52 -0700)]
gml2gv mkAttr: fix unchecked allocation failures

2 years agogml2gv mkEdge: fix unchecked allocation failure
Matthew Fernandez [Sun, 28 Aug 2022 15:52:24 +0000 (08:52 -0700)]
gml2gv mkEdge: fix unchecked allocation failure

2 years agogml2gv mkNode: fix unchecked allocation failure
Matthew Fernandez [Sun, 28 Aug 2022 15:51:53 +0000 (08:51 -0700)]
gml2gv mkNode: fix unchecked allocation failure

2 years agogml2gv pushG: fix unchecked allocation failuregml2gv pushG: fix unchecked allocation...
Matthew Fernandez [Sun, 28 Aug 2022 15:51:21 +0000 (08:51 -0700)]
gml2gv pushG: fix unchecked allocation failuregml2gv pushG: fix unchecked allocation failure

2 years agomm2gv SparseMatrix_import_matrix_market: use cgraph wrappers for allocation
Matthew Fernandez [Sun, 28 Aug 2022 15:48:00 +0000 (08:48 -0700)]
mm2gv SparseMatrix_import_matrix_market: use cgraph wrappers for allocation

The lib/cgraph/alloc.h wrappers are similar to the older lib/common/memory.h
wrappers except (1) they are header-only and (2) they live in a directory
(cgraph) that is at the root of the dependency tree. The long term plan is to
replace all use of lib/common/memory.h with lib/cgraph/alloc.h.

This change also fixes a number of unchecked allocation failures where `malloc`
was being called directly and the result was not checked.

2 years agoMerge branch 'smattr/7b19e8e0-5168-4010-9e8a-b84c871acf38' into 'main'
Matthew Fernandez [Tue, 30 Aug 2022 03:54:44 +0000 (03:54 +0000)]
Merge branch 'smattr/7b19e8e0-5168-4010-9e8a-b84c871acf38' into 'main'

gvpr: fix unchecked allocation failures

See merge request graphviz/graphviz!2816

2 years agogvpr addCase: fix unchecked allocation failure
Matthew Fernandez [Sat, 27 Aug 2022 22:31:59 +0000 (15:31 -0700)]
gvpr addCase: fix unchecked allocation failure

2 years agogvpr addBlock: fix unchecked allocation failure
Matthew Fernandez [Sat, 27 Aug 2022 22:31:04 +0000 (15:31 -0700)]
gvpr addBlock: fix unchecked allocation failure

2 years agogvpr scanArgs: fix unchecked allocation failure
Matthew Fernandez [Sat, 27 Aug 2022 22:30:16 +0000 (15:30 -0700)]
gvpr scanArgs: fix unchecked allocation failure

2 years agogvpr addBindings: fix unchecked allocation failure
Matthew Fernandez [Sat, 27 Aug 2022 22:29:00 +0000 (15:29 -0700)]
gvpr addBindings: fix unchecked allocation failure

2 years agogvpr compileProg: fix unchecked allocation failure
Matthew Fernandez [Sat, 27 Aug 2022 22:27:54 +0000 (15:27 -0700)]
gvpr compileProg: fix unchecked allocation failure

2 years agogvpr mkStmts: fix unchecked allocation failure
Matthew Fernandez [Sat, 27 Aug 2022 22:26:58 +0000 (15:26 -0700)]
gvpr mkStmts: fix unchecked allocation failure

2 years agogvpr fullColor: fix unchecked allocation failure
Matthew Fernandez [Sat, 27 Aug 2022 22:25:02 +0000 (15:25 -0700)]
gvpr fullColor: fix unchecked allocation failure

2 years agoMerge branch 'smattr/55b87137-b443-4540-845a-6cdae948b213' into 'main'
Matthew Fernandez [Tue, 30 Aug 2022 02:52:43 +0000 (02:52 +0000)]
Merge branch 'smattr/55b87137-b443-4540-845a-6cdae948b213' into 'main'

cgraph fix unchecked allocation failures

See merge request graphviz/graphviz!2814

2 years agocgraph storeFileName: fix unchecked allocation failure
Matthew Fernandez [Sat, 27 Aug 2022 15:50:12 +0000 (08:50 -0700)]
cgraph storeFileName: fix unchecked allocation failure

2 years agocgraph concatPort: fix unchecked allocation failure
Matthew Fernandez [Sat, 27 Aug 2022 15:49:00 +0000 (08:49 -0700)]
cgraph concatPort: fix unchecked allocation failure

2 years agocgraph concat: fix unchecked allocation failure
Matthew Fernandez [Sat, 27 Aug 2022 15:48:37 +0000 (08:48 -0700)]
cgraph concat: fix unchecked allocation failure

2 years agocgraph memresize: fix out-of-bounds write on allocation failure
Matthew Fernandez [Sat, 27 Aug 2022 15:45:31 +0000 (08:45 -0700)]
cgraph memresize: fix out-of-bounds write on allocation failure

Callers of this function appear to anticipate the possibility of failure, e.g.
`agrealloc`. But the function itself was attempting to zero newly allocated
memory even if the allocation call failed.

2 years agocgraph aglasterr: fix unchecked allocation failure
Matthew Fernandez [Sat, 27 Aug 2022 15:42:47 +0000 (08:42 -0700)]
cgraph aglasterr: fix unchecked allocation failure

2 years agocgraph agapply: remove unreachable 'break'
Matthew Fernandez [Sat, 27 Aug 2022 15:38:36 +0000 (08:38 -0700)]
cgraph agapply: remove unreachable 'break'

2 years agocgraph: abbreviate tag initialization
Matthew Fernandez [Sat, 27 Aug 2022 15:34:12 +0000 (08:34 -0700)]
cgraph: abbreviate tag initialization

It is not clear to me exactly what “warnings about initialization” were being
suppressed here, but I am assuming something well before C99. In C99, we have a
simpler and more concise way of doing zero initialization.

2 years agoMerge branch 'smattr/e3aab83d-a89d-4698-a6c8-a7458f971751' into 'main'
Matthew Fernandez [Tue, 30 Aug 2022 00:57:29 +0000 (00:57 +0000)]
Merge branch 'smattr/e3aab83d-a89d-4698-a6c8-a7458f971751' into 'main'

smyrna: drop 'HAVE_GTS' and 'HAVE_TRIANGLE' from the Windows builds

See merge request graphviz/graphviz!2812

2 years agosmyrna: drop 'HAVE_GTS' and 'HAVE_TRIANGLE' from the Windows builds
Matthew Fernandez [Sat, 27 Aug 2022 01:31:01 +0000 (18:31 -0700)]
smyrna: drop 'HAVE_GTS' and 'HAVE_TRIANGLE' from the Windows builds

This appears to have been a mistake in 3c8cf3624f6a8b82434115177471b6e7092f8365
that added these files. This occurred long after triangle.[ch] were removed
(ca31e3197ad25c174bd0c9d133c5479e9f3a56a1). And as of now, GTS is only available
on Windows through Vcpkg, a package manager that did not exist at the time of
3c8cf3624f6a8b82434115177471b6e7092f8365. So it seems safe to conclude Windows
really did not `HAVE_GTS` nor `HAVE_TRIANGLE` at this time.

This caused no ill-effects because defining these within Smyrna is a no-op. All
use of these macros occurs outside cmd/smyrna, in the libraries on which Smyrna
depends. But defining these unused macros was creating unnecessary confusion.

2 years agoMerge branch 'smattr/dacd6f5f-0f17-4a6b-bb5b-d4638da7c6af' into 'main'
Matthew Fernandez [Mon, 29 Aug 2022 16:29:22 +0000 (16:29 +0000)]
Merge branch 'smattr/dacd6f5f-0f17-4a6b-bb5b-d4638da7c6af' into 'main'

de-dupe common 'openFile' function into a shared header

See merge request graphviz/graphviz!2811

2 years agocmd/tools: unify common 'openFile' function into a header
Matthew Fernandez [Thu, 25 Aug 2022 15:28:22 +0000 (08:28 -0700)]
cmd/tools: unify common 'openFile' function into a header

This also addresses a number of inconsistencies between these duplicated
functions, like `sccmap` calling itself `gvpack` in its error message.

2 years agographml2gv: remove unused macros
Matthew Fernandez [Thu, 25 Aug 2022 15:01:25 +0000 (08:01 -0700)]
graphml2gv: remove unused macros

None of these have ever been in use.

2 years agoMerge branch 'doc' into 'main'
Matthew Fernandez [Mon, 29 Aug 2022 15:31:57 +0000 (15:31 +0000)]
Merge branch 'doc' into 'main'

add doxygen comments to snode

See merge request graphviz/graphviz!2629

2 years agoadd doxygen comments to snode
Costa Shulyupin [Sun, 24 Apr 2022 07:34:59 +0000 (10:34 +0300)]
add doxygen comments to snode

and make doxygen comments from regular.

2 years agosgraph: remove trailing spaces
Costa Shulyupin [Sun, 24 Apr 2022 07:20:26 +0000 (10:20 +0300)]
sgraph: remove trailing spaces

2 years agoMerge branch 'smattr/gitlab-2258' into 'main'
Matthew Fernandez [Mon, 29 Aug 2022 14:38:16 +0000 (14:38 +0000)]
Merge branch 'smattr/gitlab-2258' into 'main'

fix 'id' attribute in SVG output omitting input graph id

Closes #2258

See merge request graphviz/graphviz!2815

2 years agofix 'id' attribute in SVG output omitting input graph id
Matthew Fernandez [Sat, 27 Aug 2022 22:17:09 +0000 (15:17 -0700)]
fix 'id' attribute in SVG output omitting input graph id

When using an ID attribute on the input graph,¹ this attribute would only be
propagated to some output elements. In particular, generated `linearGradient`
and `radialGradient` elements in SVGs would be missing the ID.

Gitlab: fixes #2258

¹ https://graphviz.org/docs/attrs/id/

2 years agoMerge branch 'smattr/c56365b2-f72e-45ff-a098-d7bd1fa1f5bc' into 'main'
Matthew Fernandez [Fri, 26 Aug 2022 16:28:04 +0000 (16:28 +0000)]
Merge branch 'smattr/c56365b2-f72e-45ff-a098-d7bd1fa1f5bc' into 'main'

improve the robustness of Show_boxes

See merge request graphviz/graphviz!2809

2 years agouse 'gv_strdup' instead of 'strdup' in 'Show_boxes'
Matthew Fernandez [Wed, 24 Aug 2022 04:15:09 +0000 (21:15 -0700)]
use 'gv_strdup' instead of 'strdup' in 'Show_boxes'

This fixes some unchecked allocation failures.

2 years agouse 'agxbprint' to round points instead of casting in 'Show_boxes'
Matthew Fernandez [Wed, 24 Aug 2022 04:10:10 +0000 (21:10 -0700)]
use 'agxbprint' to round points instead of casting in 'Show_boxes'

This has the advantage of avoiding relying on values fitting in the range of an
int. Going through C stdio this way, the full range of doubles can be preserved.

2 years agouse agxbbuf for dynamic 'Show_boxes' string construction
Matthew Fernandez [Wed, 24 Aug 2022 04:02:54 +0000 (21:02 -0700)]
use agxbbuf for dynamic 'Show_boxes' string construction

We have some recent evidence¹ people are using this debug feature. This change
makes some allocations it does more robust (they now exit on failure) and
abbreviates construction in a stack buffer and then duplication into a heap
buffer into direct construction in a heap buffer.

¹ https://forum.graphviz.org/t/how-to-use-the-showboxes-attribute/1287

2 years agoMerge branch 'smattr/49d1c184-6733-4cdb-9b33-b3fba389f344' into 'main'
Matthew Fernandez [Thu, 25 Aug 2022 01:01:36 +0000 (01:01 +0000)]
Merge branch 'smattr/49d1c184-6733-4cdb-9b33-b3fba389f344' into 'main'

pathplan warning squashing

See merge request graphviz/graphviz!2803

2 years agopathplan isdiagonal: remove shadowing of globals
Matthew Fernandez [Sun, 21 Aug 2022 19:53:12 +0000 (12:53 -0700)]
pathplan isdiagonal: remove shadowing of globals

2 years agopathplan triangulate: remove shadowing of globals
Matthew Fernandez [Sun, 21 Aug 2022 19:48:41 +0000 (12:48 -0700)]
pathplan triangulate: remove shadowing of globals

2 years agopathplan Pshortestpath: use longs instead of ints for index variables
Matthew Fernandez [Sun, 21 Aug 2022 19:40:55 +0000 (12:40 -0700)]
pathplan Pshortestpath: use longs instead of ints for index variables

Within this function, these indices are sometimes calculated using pointer
arithmetic which has a long (technically `ptrdiff_t`) result. Using a long type
for these variables squashes 2 -Wconversion warnings and reduces the likelihood
of arithmetic overflows.

In future, it is possible we should convert this code to `ptrdiff_t` instead. It
is unclear if this would be an improvement, given interaction with the
surrounding code and cases where these indices are set to literals like `-1`.
Changing to `ptrdiff_t` would also be more invasive than just widening the value
range as done by this change. On most contemporary platforms, `long` and
`ptrdiff_t` are the same type, so perhaps the difference is academic.

2 years agoMerge branch 'smattr/2D929B35-2BD5-48C0-8648-38B31C6BC15F' into 'main'
Matthew Fernandez [Wed, 24 Aug 2022 16:46:49 +0000 (16:46 +0000)]
Merge branch 'smattr/2D929B35-2BD5-48C0-8648-38B31C6BC15F' into 'main'

gvmap: remove and inline some constant function parameters

See merge request graphviz/graphviz!2807

2 years agogvmap: remove 'seed' parameter from 'map_palette_optimal_coloring'
Matthew Fernandez [Sat, 28 May 2022 05:47:51 +0000 (22:47 -0700)]
gvmap: remove 'seed' parameter from 'map_palette_optimal_coloring'

This is always passed as -10.

2 years agogvmap: remove 'accuracy' parameter from 'map_palette_optimal_coloring'
Matthew Fernandez [Sat, 28 May 2022 05:45:54 +0000 (22:45 -0700)]
gvmap: remove 'accuracy' parameter from 'map_palette_optimal_coloring'

This is always passed as 0.01.

2 years agogvmap: remove 'lightness' parameter from 'map_palette_optimal_coloring'
Matthew Fernandez [Sat, 28 May 2022 05:43:30 +0000 (22:43 -0700)]
gvmap: remove 'lightness' parameter from 'map_palette_optimal_coloring'

This is always passed as "0,100".

2 years agoMerge branch 'smattr/354B5E18-2096-4F8B-B09E-32C5E9E5E1F7' into 'main'
Matthew Fernandez [Wed, 24 Aug 2022 15:05:04 +0000 (15:05 +0000)]
Merge branch 'smattr/354B5E18-2096-4F8B-B09E-32C5E9E5E1F7' into 'main'

sparse simplification

See merge request graphviz/graphviz!2806

2 years agosparse: remove unnecessary casts in 'SparseMatrix_sum_repeat_entries'
Matthew Fernandez [Mon, 23 May 2022 14:41:08 +0000 (07:41 -0700)]
sparse: remove unnecessary casts in 'SparseMatrix_sum_repeat_entries'

2 years agosparse: remove unused 'what_to_sum' from 'SparseMatrix_sum_repeat_entries'
Matthew Fernandez [Mon, 23 May 2022 14:39:23 +0000 (07:39 -0700)]
sparse: remove unused 'what_to_sum' from 'SparseMatrix_sum_repeat_entries'

This function is never called with `what_to_sum` equal to `SUM_REPEATED_NONE`.

2 years agosparse: remove always true branch in 'SparseMatrix_sum_repeat_entries'
Matthew Fernandez [Mon, 23 May 2022 14:37:07 +0000 (07:37 -0700)]
sparse: remove always true branch in 'SparseMatrix_sum_repeat_entries'

`what_to_sum` can only take on two values, `SUM_REPEATED_NONE` and
`SUM_REPEATED_ALL`. If it is `SUM_REPEATED_NONE` there is an early exit at the
beginning of this function.

2 years agoMerge branch 'smattr/9cac6136-572d-4e70-a9c9-ec277f91ba27' into 'main'
Matthew Fernandez [Wed, 24 Aug 2022 05:12:22 +0000 (05:12 +0000)]
Merge branch 'smattr/9cac6136-572d-4e70-a9c9-ec277f91ba27' into 'main'

graphml2gv: remove unused struct members

See merge request graphviz/graphviz!2801

2 years agographml2gv: remove unused 'listen'
Matthew Fernandez [Sat, 20 Aug 2022 15:58:05 +0000 (08:58 -0700)]
graphml2gv: remove unused 'listen'

This member was always false.

2 years agographml2gv: remove unused 'globalAttrType'
Matthew Fernandez [Sat, 20 Aug 2022 15:56:16 +0000 (08:56 -0700)]
graphml2gv: remove unused 'globalAttrType'

This member was always `TAG_NONE`.

2 years agographml2gv: remove unused 'compositeReadState'
Matthew Fernandez [Sat, 20 Aug 2022 15:54:01 +0000 (08:54 -0700)]
graphml2gv: remove unused 'compositeReadState'

It has never been possible to set this member to true.