Commit Graph

92 Commits

Author SHA1 Message Date
Darryl L. Miles 239366d4b6 grTk3.c: warning: suggest parentheses around '-' in operand of '&'
GCC14 -Wall cleanup series [-Wparentheses]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 64772655dc 38 x warning: suggest parentheses around assignment used as truth value
EFdef.c:110:12: warning: suggest parentheses around assignment used as truth value
EFdef.c:154:12: warning: suggest parentheses around assignment used as truth value
EFdef.c:167:12: warning: suggest parentheses around assignment used as truth value
EFflat.c:546:17: warning: suggest parentheses around assignment used as truth value
EFflat.c:798:12: warning: suggest parentheses around assignment used as truth value
EFflat.c:930:13: warning: suggest parentheses around assignment used as truth value
EFflat.c:1152:12: warning: suggest parentheses around assignment used as truth value
EFflat.c:1157:13: warning: suggest parentheses around assignment used as truth value
EFhier.c:84:12: warning: suggest parentheses around assignment used as truth value
EFhier.c:261:12: warning: suggest parentheses around assignment used as truth value
EFhier.c:489:12: warning: suggest parentheses around assignment used as truth value
EFhier.c:682:12: warning: suggest parentheses around assignment used as truth value
EFname.c:325:12: warning: suggest parentheses around assignment used as truth value
EFname.c:584:13: warning: suggest parentheses around assignment used as truth value
EFname.c:632:16: warning: suggest parentheses around assignment used as truth value
EFname.c:765:16: warning: suggest parentheses around assignment used as truth value
EFname.c:977:12: warning: suggest parentheses around assignment used as truth value
EFsym.c:113:13: warning: suggest parentheses around assignment used as truth value
EFsym.c:164:9: warning: suggest parentheses around assignment used as truth value
EFvisit.c:322:12: warning: suggest parentheses around assignment used as truth value
EFvisit.c:627:12: warning: suggest parentheses around assignment used as truth value
EFvisit.c:881:16: warning: suggest parentheses around assignment used as truth value
EFvisit.c:917:12: warning: suggest parentheses around assignment used as truth value
grTk1.c:1325:9: warning: suggest parentheses around assignment used as truth value
grTk1.c:1342:9: warning: suggest parentheses around assignment used as truth value
grTk1.c:1757:9: warning: suggest parentheses around assignment used as truth value
grTk1.c:1766:9: warning: suggest parentheses around assignment used as truth value
grTk5.c:177:12: warning: suggest parentheses around assignment used as truth value
grTOGL1.c:1095:9: warning: suggest parentheses around assignment used as truth value
grTOGL1.c:1111:9: warning: suggest parentheses around assignment used as truth value
grTOGL1.c:1542:13: warning: suggest parentheses around assignment used as truth value
grTOGL1.c:1551:13: warning: suggest parentheses around assignment used as truth value
grTOGL5.c:201:12: warning: suggest parentheses around assignment used as truth value
grTCairo1.c:1093:13: warning: suggest parentheses around assignment used as truth value
grTCairo1.c:1109:13: warning: suggest parentheses around assignment used as truth value
grTCairo1.c:1493:21: warning: suggest parentheses around assignment used as truth value
grTCairo1.c:1502:21: warning: suggest parentheses around assignment used as truth value
grTCairo5.c:202:16: warning: suggest parentheses around assignment used as truth value

GCC14 -Wall cleanup series [-Wparentheses]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 967b41343b GCC14: warning: missing braces around initializer
GCC14 -Wall cleanup series [-Wmissing-braces]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 65a0dc45dc graphics: windowname[] potential buffer overrun warning
GCC14 loud default warnings series
2024-10-09 20:39:12 -04:00
Darryl L. Miles 54f49829f2 graphics: multiple definition of `various_x11_symbols'
Solution is to make the grX11thread.c and grX11su1[5].c versions
the official location.  Another solution maybe to split them into
their own file grX11common.c that would be shared.

Multiple configurations tested, tested configurations assume X11
is available.  The configuration wording indicates X11 must be
available for all graphics enabled build configurations.

Affected symbols appear to have multiple definitions:
grCursors
grXdpy
grXscrn
pipeRead
pipeWrite
Xhelper
grVisual

GCC14 and linker will not link the final executable due to this.

GCC14 --without-tk --without-tcl
Related issue: https://github.com/RTimothyEdwards/magic/issues/323
2024-10-09 20:35:19 -04:00
Darryl L. Miles e5c3e703c3 HashLookOnly(): passing argument 2 of 'HashLookOnly' makes pointer from integer without a cast
Also HashFind()

GCC14 --without-tk --without-tcl
Related issue: https://github.com/RTimothyEdwards/magic/issues/323
2024-10-09 20:35:19 -04:00
Tim Edwards dba6f99d93 Updated the revision number to go along with the merge of pull
request #325 from Daryl Miles.  Made a few simple style changes
to conform to (what is vaguely defined as) the overall programming
style for magic (passed down from John Ousterhout).
2024-10-01 12:56:31 -04:00
Darryl L. Miles 18a4dddc2b fix: read of uninitialized data at inChar[0]
This is a defensive fix, might cause unexpected program exit if triggered.
The loop will iterate at least once when nbytes==0, but this value
indicates XLookupString did not fill in any data, so the entire buffer
is undefined.

Using memset() before or inChar[0]=0 after XLookupString did not fix
the issue.  Using inChar[0]=0 immediately before the loop did fix as
well.  But this patch seems to be the best approach.
2024-10-01 12:43:27 -04:00
Darryl L. Miles 60fe6427da graphics/grX11su1.c: Dereference of null pointer
Looks like the code below requires w!=NULL to do anything useful.
So when w==NULL we don't continue processing X11 Event.

SonarCloud
graphics/grX11su1.c:895 Dereference of null pointer
https://sonarcloud.io/project/issues?open=AZJB163RNGfDNup0Ri4p&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 01f9f2246b graphics/grX11su1.c: Dereference of null pointer
Looks like the code below requires w!=NULL to do anything useful.
So when w==NULL we don't continue processing X11 Event.

SonarCloud
graphics/grX11su1.c:842 Dereference of null pointer
https://sonarcloud.io/project/issues?open=AZJB163RNGfDNup0Ri4o&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 29ee094074 graphics/grOGL1.c Dereference of null pointer
Looks like the code below requires mw!=NULL to do anything useful.
So when mw==NULL we don't continue processing X11 Event.

SonarCloud
graphics/grOGL1.c:563 Dereference of null pointer
https://sonarcloud.io/project/issues?open=AZJB16z6NGfDNup0Riss&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles be258c6557 graphics/grOGL1.c: non-void function does not return a value
Making oglSetProjection() return void, like toglSetProjection()

SonarCloud
graphics/grOGL1.c:408 non-void function does not return a value
https://sonarcloud.io/project/issues?open=AZJB16z6NGfDNup0Riro&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles ae0cdd9fea graphics/grClip.c Branch condition evaluates to a garbage value
This is technically a false positive as grClipPoints() will always
initializes a value to ok1 and ok2 when called.  The function is in
the same compile unit, so probably the compiler can see this as well
and potentially not perform the initiailization begin performed in
this commit.

But to quieten and remove this item from the analysis report
assigning an initialization value.

SonarCloud
graphics/grClip.c:451 Branch condition evaluates to a garbage value
https://sonarcloud.io/project/issues?open=AZJB160MNGfDNup0Rit4&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 10442b6534 graphics/cairo_orig/grTCairo5.c uninitialized local variable
Looks like old code.  Based on cairo_fill() action state this is initialized to
no-op by default.

SonarCloud
graphics/cairo_orig/grTCairo5.c:107 The left operand of '!=' is a garbage value
https://sonarcloud.io/project/issues?open=AZJB16wANGfDNup0RiiZ&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl L. Miles 5e00e3fe1b graphics/cairo_orig/grTCairo3.c uninitialized value
Looks like old code.  Looks like local variable 'j' could be removed.
Initialization lowers the severity of concern in this area.
The 'j' variable is now written but never read.

SonarCloud
graphics/cairo_orig/grTCairo3.c:492
The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage
https://sonarcloud.io/project/issues?open=AZJB16voNGfDNup0Rig_&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl Miles f809b2dfac graphics/grTk1.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 98: Wrong type of arguments to formatting function (#44)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:13 -04:00
Darryl Miles 4ca98dc31b graphics/grCMap.c: Incorrect return-value check for a 'scanf'-like function
Fix code scanning alert no. 150: Incorrect return-value check for a 'scanf'-like function (#8)

* Create codeql.yml

* Fix code scanning alert no. 150: Incorrect return-value check for a 'scanf'-like function

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Update grCMap.c

* AI suggested '< 1', DLM edited to '<= 0' easier for a human to reason about ?

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:12 -04:00
Darryl Miles 39e76f3f31 graphics/grDStyle.c: Incorrect return-value check for a 'scanf'-like function
Fix code scanning alert no. 151: Incorrect return-value check for a 'scanf'-like function (#7)

* Create codeql.yml

* Fix code scanning alert no. 151: Incorrect return-value check for a 'scanf'-like function

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Update grDStyle.c

* AI suggested '< 1', DLM edited to '<= 0' easier for a human to reason about ?

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-01 12:36:12 -04:00
Tim Edwards 98f3b39dc2 Two small tweaks on plot filename behavior: (1) "plot svg" without
a filename causes an error instead of generating a trash filename
or crashing, while (2) "plot pnm" with a filename that has the ".pnm"
extension does not add another ".pnm" extension to the end of it.
2023-10-17 20:01:39 -04:00
Tim Edwards c1f4555ba0 Corrected behavior of "load ... -dereference" to bring back a
previous behavior that had inadvertently been changed.  In recent
versions, "load <absolute_path> -dereference" would incorrectly
apply the dereferencing to <absolute_path> rather than just its
subcells.  Cleaned up the code around DBCellRead() in the process,
so everything is more straightforward (although probably more
could be done in that regard).
2023-04-18 11:01:58 -04:00
Tim Edwards d8f926865d Modified the behavior of cell reading, mainly with respect to
dereferencing, and making the behavior of "load" on the command
line (i.e., loading a cell from a file) the same as the
behavior of loading a cell as a result of expanding an unloaded
instance.  In both cases, if "load -dereference" is used, and
a cell does not exist in any search path but does exist in the
original location, without dereferencing, then the cell will be
loaded from the original location.  Also:  Corrected an error
that has existed since adding the capability to read compressed
files, which causes magic to crash when attempting to run the
"crash recover" command (because that routine was mixing
compressed and regular file stream calls).
2023-03-20 21:00:35 -04:00
Tim Edwards d229aefb15 A handful of changes after applying pull request #191 from
Alessandro De Laurenzis.  That pull request cleaned up the vast
majority of compiler warnings.  However, that cleanup exposed a
few additional warnings pointing to errors in the code that needed
fixing.  The code now compiles cleanly except for one warning
about redefined CAD_DIR that I have not looked into.
2022-10-29 09:57:41 -04:00
Alessandro De Laurenzis 70ebfb831b Define Cairo functions prototypes only when support is enabled 2022-10-29 06:07:46 +02:00
Alessandro De Laurenzis 68cecd5382 C99 code compat when configured with no TCL support 2022-10-29 06:07:46 +02:00
Alessandro De Laurenzis 1c343584e9 graphics/grTkCommon.c: remove OGL includes
No references to OpenGL here, so headers not needed.
While there, replace panic() with TxError() + MainExit (+ include
utils/main.h for C99 compat).
2022-10-29 06:07:46 +02:00
Alessandro De Laurenzis b306a39560 Compatibility with C99 standard
This commit makes the code (mostly) C99-compatible, enabling to compile
it without the -Wno-error=implicit-function-declaration flag. This
way, Magic becomes usable on arm64 architectures, specifically on Apple
computers with M1/M2 SoC.
2022-10-29 06:07:46 +02:00
Tim Edwards 65b54e0cd5 Corrected a stack corruption error (that I have never seen in
practice but which was detected by AddressSanitizer.  Also
corrected a crash condition in the absence of a window;  also
hard to reproduce.
2022-09-27 10:43:04 -04:00
Tim Edwards 2462d6f220 I discovered that for large designs, running DBWredisplay will take
significant amounts of time even though there is no display to
receive the result.  However, the "suspendall" command only works
if a window exists.  The obvious solution is to set GrDisplayStatus
to DISPLAY_SUSPEND whenever magic is run with the "-dnull" option.
This should help speed up a lot of scripts, in particular where
designs are large.
2021-01-12 12:46:43 -05:00
Dan Moore 8dba03cebf Set GrClosePtr back to NULL before calling MainExit()
to squash the seg fault. It appears that calling GrTkClose
before graphics are fully initialized causes this.
2021-01-04 08:59:20 -05:00
Tim Edwards 75a18053f8 Modified the CIFGenLayer() routine to be aware of when it is called during
hierarchical processing from CIFGenSubcells() and CIFGenArrays(), and to
avoid certain operators that are useless and harmful when applied
hierarchically; namely squares, slots, bbox, boundary, and net.
2020-11-12 10:34:27 -05:00
Tim Edwards 3203eec28c Modified the "bloat-all" cifoutput operator to allow operations on
templayers.  This permits some useful interactions like growing to
the size of a bounding box, or abutment box, as well as many other
possibilities.  Also:  Corrected the use of "cif see" for the boundary
(abutment box) layer, which was not working because the "cif see"
command uses a flattened CellDef that does not have the boundary
property of the cell it was flattened from.
2020-05-26 14:29:36 -04:00
Tim Edwards 2af38a4191 Updates from running the fix-ending-whitespace script. 2020-05-23 17:13:14 -04:00
Tim 'mithro' Ansell 516ae506d7 Remove all the $XXX: YYY$ 2020-05-23 17:00:38 -04:00
Tim Edwards 80fa495103 Removed the Depend files, which were being tracked with .gitignore
pointing to Depend instead of */Depend.
2020-03-13 15:39:08 -04:00
Tim Edwards 06eef6e324 Corrected ext2sim.c calls to hierAP and others using "scale" and
declaring it to be an integer when it is actually a float.  This
will cause magic to crash when using, e.g., "ext2sim -f su".
2020-02-11 10:21:36 -05:00
Tim Edwards 2ca9511152 Added fix for SVG output. This brings back the original behavior
of generating scalable output.  Some libcairo update had caused
the output to use the wrong version of SVG by default, which
generates an SVG-wrapped PNG data block, which is not scalable,
and not what was intended with the "plot svg" command.
2020-02-07 11:38:00 -05:00
Tim 'mithro' Ansell 4f30e76688 Make SVG output actually SVG again.
Currently the SVG output is a SVG file with an embedded `image/png`
file. Restricting to `CAIRO_SVG_VERSION_1_2` means the file goes back to
being a vector.

Signed-off-by: Tim 'mithro' Ansell <me@mith.ro>
2020-02-07 17:31:05 +01:00
Tim Edwards bc00b5578b Implemented a new configuration variable "dist_prefix" for
distributed installations, where the immediate installation location
is different from the final installation location, but in the case
where it is not desirable to put the entire install hierarchy as a
subdirectory of DESTDIR.
2020-01-28 10:40:01 -05:00
Tim Edwards 82e33248f2 Corrected dereferencing of cell dependencies, which was being applied
only at the time of running the command "load".  But cells are generally
loaded only on an as-needed basis, so the dereferencing option must be
saved as a flag in the cell and honored whenever its subcells are expanded
or otherwise read at a later time.
2020-01-02 10:13:04 -05:00
Tim Edwards 0eb3b1fe1c Corrected an error in ext2spice related to the recent modification to get
rid of redundant port entries in subcircuits.  There is still an outstanding
issue as to whether nodes and connections need to be recursively iterated
to the hierarchy bottom.  The current fix corrected the test case.  Also,
added a "-dereference" option to the "load" command to revert to the
original behavior of using only search paths from "addpath" when searching
for files to load.
2019-11-14 15:18:26 -05:00
Tim Edwards c31b305848 Corrected the dependency list in the Makefile for "modules", which
should depend on database/database.h;  otherwise running distributed
make can start compiling modules before the database.h file is
created.
2019-07-14 12:07:38 -04:00
Tim Edwards 1f3a512909 Added a "plot svg" command that, when used in conjuction with the
Cairo graphics package (magic -d XR), will map the display onto
an SVG surface and save it to a file using the Cairo SVG backend.
Due to the simplicity of the mapping, there are no options to this
plot command;  it just creates a file that is a (scalable!)
replica of the layout window.
2019-03-12 13:29:24 -04:00
Tim Edwards bb0af34441 Corrected an obscure error that causes the background of the layout
window to change after hiding a layer using the toolbar and then
refreshing the layout.  Fixed by saving and restoring the graphics
state around the routine that configures the toolbar image.  Also
added a check to CifPaintCurrent to guard against using an unassigned
ClientData record as a pointer (causes a crash), and added braces
around "expr" values in the Tcl wrapper, which reportedly results in
faster execution of the expression.
2018-10-23 08:44:04 -04:00
Tim Edwards 54e6171e9c Corrected an error that prevents the compile option
"--enable-cairo-offscreen" from working.  Because the option
does not run the full Cario initialization, the grTCairoVisualInfo
is not set, and the first attempt to create a Cairo surface
fails with a segfault.
2018-09-13 10:19:48 -04:00
Tim Edwards cfccdb84c1 Rewrote the configuration scripts, makefiles, and some initialization
routines to use the Tcl and Tk stubs libraries.
2017-10-13 10:28:07 -04:00
Tim Edwards 9c22e2e059 Corrected duplicate global variable grVisualInfo between grTOGL1.c
and grTCairo1.c.
2017-10-12 10:42:13 -04:00
Tim Edwards b5dd3304ee Additional small correction. 2017-10-04 21:57:54 -04:00
Tim Edwards 7ed43ba964 Removed the call to glFinish() because it appears mostly to
cause synchronization delays.
2017-10-04 15:40:11 -04:00
Tim Edwards 00556d2999 Removed two temporary backup files. 2017-10-04 14:58:07 -04:00
Tim Edwards 93bcfeb093 Finally worked out how to correctly use the OpenGL general-purpose
frame buffers and render buffers, and use fast frame buffer bit
block transfers to do copies to and from backing store.  Also found
a long-standing problem where multiple windows fail to refresh
properly in OpenGL and Cairo interfaces due to a lack of calling
GrLock() and GrUnlock() around the call to fetch backing store
after an expose event.  The use of the general purpose frame
buffer allows magic to avoid calling any indirect rendering methods
and should now (finally) allow magic to run in OpenGL mode over a
VNC.  Use of direct rendering methods only also means that magic
does not need to be compiled with the ad hoc switch to have Cairo
handle drawing into pixmaps for the icons (this remains to be
tested).
2017-10-04 14:53:01 -04:00