Commit Graph

2057 Commits

Author SHA1 Message Date
Darryl L. Miles a1f7e4ed5e lef: post K&R constify ripple
These functions are using data that is already const.
2025-02-22 21:48:17 -05:00
Darryl L. Miles f7c550e82f defRead.c: DefRead() incorrect arg0 to LefParseEndStatement() 2025-02-22 21:48:17 -05:00
Darryl L. Miles 25ec9fccef K&R lef.h lefInt.h: conversion to ANSI
K&R obsolete syntax removal for C23 compatibility series
2025-02-22 21:48:17 -05:00
Darryl L. Miles acf0e474e8 K&R lefInt.h: missing prototype removal
Function does not appear to exist:
 extern char *LefGetInput();

K&R obsolete syntax removal for C23 compatibility series
2025-02-22 21:48:17 -05:00
Darryl L. Miles a764fdbbd1 CodeQL MemoryMayNotBeFreed.ql grTCairo1.c GrTCairoPlotSVG()
created use of 'alloc' local variable to track when an allocation occurred
so exit path logic is more straight forward for compiler/analyser to see
potential optimisations.

the previous version was probably working just fine
2025-02-22 21:35:23 -05:00
Darryl L. Miles e565b4c360 CodeQL MemoryMayNotBeFreed.ql NMnetlist.c NMWriteNetlist()
created use of 'alloc' local variable to track when an allocation occurred
so exit path logic is more straight forward for compiler/analyser to see
potential optimisations.

no attempt to free memory was made previously
2025-02-22 21:35:23 -05:00
Darryl L. Miles 37fa75dd77 CodeQL MemoryMayNotBeFreed.ql ResRex.c ResCheckSimNodes()
created use of 'alloc' local variable to track when an allocation occurred
so exit path logic is more straight forward for compiler/analyser to see
potential optimisations.
2025-02-22 21:35:23 -05:00
Darryl L. Miles c33b6be2bb CodeQL MemoryMayNotBeFreed.ql rtrChannel.c RtrChannelRoute()
Unclear with all the flip operations if there is some kind of attachment
(exchange of channels), the other 2 channels created in the function
are also cleaned up.
2025-02-22 21:35:23 -05:00
Darryl L. Miles b5d068b0ea CodeQL MemoryMayNotBeFreed.ql rtrCmd.c CmdRoute() 2025-02-22 21:35:23 -05:00
Darryl L. Miles cb9333804a CodeQL MemoryMayNotBeFreed.ql rtrCmd.c CmdRoute()
temporary channel created to run command is not cleaned up
2025-02-22 21:35:23 -05:00
Darryl L. Miles 822a95ab35 CodeQL MemoryMayNotBeFreed.ql antennacheckVisit()
Looks like straight forward exit path doesn't cleanup locally malloc
block.
2025-02-22 21:35:23 -05:00
Darryl L. Miles 7508a9e6b7 CodeQL MemoryMayNotBeFreed.ql calma/**
Looks straight forward lost pointer to recently malloced block
2025-02-22 21:35:23 -05:00
Darryl L. Miles 99c448407c CodeQL LargeParameter.ql: large objects returned (around fd_set usage)
now using pointers (fd_set*)
constify API where possible
2025-02-22 21:31:22 -05:00
Darryl L. Miles 6a537c4659 CodeQL IncorrectNotOperatorUsage.ql rtrDcmppose.c rtrCLEAR() usages
Maybe it was a single bit and '!' operator inverted a single bit, but it
 appears to be a 4-bit mask today.

TODO check rtrMARKED() this looks like it uses '&' operator is in use
 but from the context of a bitmask maybe this should be '|' operator.
2025-02-22 21:31:22 -05:00
Darryl L. Miles ca9229b35a CodeQL MissingNegativtyTest.ql ttype>=0 ResSimSubckt()
This variable is used as array index, but the extGetDevType() API allows
a negative return to occur.
2025-02-22 21:31:22 -05:00
Darryl L. Miles ad1d9923f9 CodeQL MissingNegativtyTest.ql magictype>=0 defWrite.c
defnodeVisit()
defblockageVisit()

This variable is used as array index, but the DBTechNameType() API allows
a negative return to occur.
2025-02-22 21:31:22 -05:00
Darryl L. Miles 38b25c5d34 CodeQL InconsistentNullnessTest.ql ourgl != NULL
ourgl local variable is set to a non-NULL value (first initialization)
in code that is in lines below where it is dereferenced in a loop.
Somewhere in the loop there is a point where the precondition of ourgl
being set to non-null is expected.
ASSERT added.
2025-02-22 21:31:22 -05:00
Darryl L. Miles d18b40d401 CodeQL LateNegativeTest.ql defRead.c routerLayer>=0
Code nearby tests 'routeLayer' for negativeness, but it is set and then
used as array index without such a test.
ASSERT added.
2025-02-22 21:31:21 -05:00
Tim Edwards 8ebad7d1a9 Implemented the fix to an expression that should have been logical-
AND and not bitwise-AND, as pointed out in PR #376 by Darryl Miles.
2025-02-22 21:15:45 -05:00
Darryl L. Miles a60259ab63 CodeQL FileMayNotBeClosed.ql PaCheckCompressed() apparently leaks an 'fd'
CodeQL complains of a _potential_ leak (I can't see it), seems false
positive but also a clear case to use POSIX access(R_OK) instead.
2025-02-22 21:02:49 -05:00
Darryl L. Miles e88dcba1c5 CodeQL File{MayNot,Never}BeClosed.ql file-handle resource leaks
Guided by CodeQL static code analyser.

FileMayNotBeClosed.ql
FileMayNeverBeClosed.ql

The trick with "if(fp != stdout)" is problematic (to analyser) as
technically 'stdout' can be a global pointer that COULD be modified any
time, so it might have changed between the fopen() and fclose() calls so
the close MAY NEVER occurs (which is problem the analyzer can see).

So local state is maintained as a bool which will also clarify to the
compiler see the intention without concern for external stdout
modification.

Some items appear to be out and out leaks when certain commands are use.
2025-02-22 21:02:49 -05:00
Tim Edwards 7960020f7c Updated the HTML documentation on the "wire" command to add the
new syntax implemented earlier today that preserves interactive
wiring moves when logging commands.
2025-02-22 21:00:04 -05:00
Darryl L. Miles 554327f1d3 plowSrShadowXxx() callback plowShowShadow() correct return type
was void, now int.
2025-02-22 20:58:59 -05:00
Darryl L. Miles 97ff043c1a plowInitRule() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles 93054eb4e6 plowPropagateRect() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles 8ee328811c plowSrShadowInitial() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles 86bb97948f plowSrShadowBack() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles cfd71f1b5d plowSrShadow() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles d149c83a8a plowSrOutline() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles cf0f9311ab plowFindWidthBack() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles 2ff6d6113d plowFindWidth() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles bc5a4a0fb1 Plow() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles 6db34b6aa9 gaMazeRoute() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles 97189f6219 irRoute.c: LayerInTouchingContact() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles 90c03738ce ExtPerim.c: extEnumTilePerim() pass by-pointer const TileTypeBitMask* instead of by-value
sizeof(TileTypeBitMask) == 32
2025-02-22 20:58:59 -05:00
Darryl L. Miles e8d7888300 extract.h/EFVisit.h include database.h for TileTypeBitMask
This has a knock on effect of causing EFvisit.c to require database.h
to be defined BEFORE the EFint.h due to an identical copy of ArrayInfo
type being present in both files.

Maybe there should be database_arrayinfo.h ?  To remove the copy.
2025-02-22 20:58:59 -05:00
Tim Edwards 144c22f579 Added the ability to translate pointer-based "wire" commands from
interactive wiring into coordinate-based commands.  Added new
command extensions for "wire leg", "wire vertical", "wire type",
and "wire horizontal".  Modified the command logging such that
"wire show" (which does not modify layout) does not get logged,
which avoids unnecessary logging of mouse movement.
2025-02-22 17:06:06 -05:00
Tim Edwards c4a2a54cb7 Corrected a syntax error in the old (non-Tcl/Tk) grX11su1.c code
that was introduced with a slew of updates back in October, as
noticed and reported (with solution) by J. Schonberg.
2025-02-15 22:20:50 -05:00
Tim Edwards 09ff52cdc0 One additional fix which allows "gds write" to continue after a
cell is found to be missing, if "gds allow undefined" has been
set.
2025-02-15 13:49:14 -05:00
Tim Edwards 41d77558b7 Fixed an error in which using the command option "gds allow undefined"
will cause a segmentation fault.
2025-02-15 13:43:01 -05:00
Tim Edwards df84a36659 Added code to handle the case where GDS_FILE points to a filename
that has since been compressed and given a ".gz" extension.
Removed code that uses a system call to "gunzip" and "gzip" when
the target file is compressed, since the compression is handled
in the code.
2025-02-12 16:28:43 -05:00
Tim Edwards 38b3d53b5f Modified the behavior of "select area subcell" so that it no longer
requires that subcells be unexpanded in order to select them.  This
seems to be more in line with what one would expect from the
documented description of the "select area" command, and more in
line with common-sense expectations.
2025-02-09 14:51:40 -05:00
Tim Edwards cd80d38d52 Fixed a rather long-standing error, which is that when scaling of
"MASK_HINTS" was implemented, it was put into a routine that
scales all coordinate-related properties, including "FIXED_BBOX",
but the original code that scaled only "FIXED_BBOX" was never
removed, resulting in the bounding box getting incorrectly scaled
twice by any grid scaling.
2025-02-09 12:48:22 -05:00
Tim Edwards 619191c6dd Corrected a crash condition caused by yesterday's commit, if the
new CIF operator is used in a tech file.  Reworked yesterday's
commit to add more related operators, so there are now four new
ones (also renamed them):  interacting, noninteracting, overlapping,
and nonoverlapping.  "interacting" now means overlapping or touching;
so the four cases allow all variations of adjacency between the two
material types.
2025-02-05 14:49:32 -05:00
Tim Edwards a5653c8fca Added a new CIF operator "not-interact" which is complementary to
"interact", because it was trivially easy to implement and saves
processing vs. doing the same thing with two templayers and an
"and-not" operator.
2025-02-04 20:43:30 -05:00
Tim Edwards 21b810b375 Added a new CIF operator "interact" which enumerates disjoint
regions of a given type and retains only those regions which
interact with (overlap) another given type.  Both sets of types
can be either magic database types or CIF temp layers.  This will
allow the implementation of rules that were not previously
possible.
2025-02-04 17:21:26 -05:00
Tim Edwards 72368a3d13 Added a fallback method for "extresist" whenever a device terminal
connection to a net that has been decomposed into a resistor array
cannot be found.  This indicates some fundamental error in the way
extresist works.  However, it should not be producing an invalid
and unsimulatable netlist.  Instead, it makes an arbitrary connection
from the device terminal to the resistor array and adds an entry in
the output netlist (.res.ext file).  This results in a poor
representation of the resistor network to that terminal, but an
otherwise simulatable netlist.  A warning is issued to note that an
arbitrary connection has been made.  This is most typically a
"garbage in, garbage out" situation in which insufficient information
exists in a layout to inform magic on which direction current is
traveling through a net.  However, it should be possible to rewrite
the extresist code so that magic makes somewhat informed decisions
about current paths and produces a halfway decent representation of
the actual net, instead of just giving up on the detailed extraction.
2025-01-15 10:38:10 -05:00
Tim Edwards 4445663cb1 Modified a routine to return a valid string when attempting to
generate a name for an instance that is set to NULL.  It is not
clear to me by an instance would have a NULL name, but apparently
it can happen, and should not crash magic.
2025-01-12 17:36:05 -05:00
Tim Edwards 1cec414618 Added the contents of the "readline" module back. This is
generally unused, as it is incompatible with the Tcl/Tk build of
magic.  However, I had not intended to remove it, only move the
name from "readline-4.3" to "readline".  But "readline/readline"
was in .gitignore, which caused the contents to be removed from
the repository.  This commit restores those files, and also
prevents the readline directory Makefile from making a symbolic
link called "readline" to itself, which was causing compile-time
issues.  The readline code is only kept for backwards compatibility
with ancient versions of magic not using the Tcl/Tk interpreter.
2025-01-10 09:58:57 -05:00
Tim Edwards 82a1dc98b4 Updated the version to go along with the merge of pul request 2025-01-10 09:21:28 -05:00