Commit Graph

245 Commits

Author SHA1 Message Date
Darryl L. Miles 00b479301f tiles: TiPlaneRect const ripple 2025-04-09 15:07:28 -04:00
Darryl L. Miles 1a84eab4ce Plane[GS]etHint() added to encapsulate access to Plane->pl_hint
This is ground work to intercept usage and validate changes in
this area.

Fixed conflicts with earler patch in extract/ExtNghbors.c
2025-04-09 15:02:59 -04:00
R. Timothy Edwards dde7144966 Modified the behavior of SelectCopy() so that it surveys cell
instance names in both the selection and in the root edit CellDef,
and then wipes duplicate names from the selection and regenerates
unique IDs.  This avoids the unexpected behavior displayed by
magic in which a "copy" function renames the *original* instance
and gives the original name to the copied instance.  This is not
only unexpected, but causes an error in which "undo" after
multiple copies fails to remove earlier copies because the name
change was not recorded, and the instance can no longer be found
by name.
2025-03-26 14:45:46 -04:00
Darryl L. Miles 9aef87c355 database: TxDialog() constification ripple 2025-02-23 10:24:40 -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 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 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
Darryl L. Miles 6afadf9809 gcc11 -Wall -Wpedantic cleanup (post __attribute__) 2025-01-06 16:25:38 +00:00
Darryl L. Miles aa5ddbaa58 database/database.h.in: const PaintResultType *resultTbl
Probably forgot to edit database.h.in template file (and edited
database.h) when working locally.
2025-01-06 16:24:02 +00:00
Darryl L. Miles ac56dd71a9 cif: use 'const' with readonly data (also consumer DBpaint)
This then required a cascade of function APIs to also now receive
const arguments.

This reduces the .data segment use of this module.
2025-01-04 11:31:17 -05:00
Darryl L. Miles 0ce8265570 TCL9: ClientData macro assignment and access usage 2025-01-04 11:08:01 -05:00
Tim Edwards df19d62f51 Corrected code in DBtpaint2.c handling the setup of paint/erase
tables for contacts, where an error was pointed out by Darryl
Miles (github issue #339).
2024-12-26 16:28:43 -05:00
Darryl L. Miles bd51438c15 database/DBio.c: PaExpand() constify update call-site 2024-12-26 15:20:58 -05:00
Darryl L. Miles b8dae95515 Lookup() constify call-site
extflat/EFantenna.c: Lookup() constify call-site
drc/DRCtech.c: Lookup() constify call-site
dbwind/DBWelement.c: Lookup() constify call-site
database/DBtpaint.c: Lookup() constify call-site
commands/CmdTZ.c: Lookup() constify call-site
commands/CmdRS.c: Lookup() constify call-site
commands/CmdLQ.c: Lookup() constify call-site
commands/CmdFI.c: Lookup() constify call-site
commands/CmdE.c: Lookup() constify call-site
commands/CmdCD.c: Lookup() constify call-site
commands/CmdAB.c: Lookup() constify call-site
cmwind/CMWcmmnds.c: Lookup() constify call-site
2024-12-26 15:20:58 -05:00
Darryl L. Miles fb8f7b94aa LookupStructFull() constify call-site
txInput.c: LookupStructFull() constify call-site
DBlabel.c: LookupStructFull() constify call-site
2024-12-26 15:20:58 -05:00
Darryl L. Miles c7f99e076e DBcount.c: DBTreeCountPaint() unify return type of hiercount() callback
The call-site does not expect a return value.
The use case in command/Cmdwizard.c is written to be void.

So a resolution was needed.
2024-12-26 13:13:14 -05:00
Darryl L. Miles 7ebaba6b39 DBcount.c: clarify function documentation of hiercount() callback
DBTreeCountPaint(def, count, hiercount, cleanup, cdata)
 callback hiercount()

The K&R function prototype syntax in the documentation might confuse
reader into which argument order is correct (as a modern developer
might be out of practice with interpreting K&R syntax)
2024-12-26 13:13:13 -05:00
Tim Edwards 89b6f4f92b Corrected an error with the bloat-all CIF operator in which
bloat-all would fail to operate from the top layer of a contact
type due to the use of DBplane(type) instead of counting all
planes of the contact.
2024-12-16 21:52:11 -05:00
Tim Edwards 8b34aa78a9 Corrected a long-standing crash condition that happens when a
generated cell is modified multiple times.  If the original cell
is orphaned (no longer used anywhere in the design), it is deleted.
However, an instance of the cell may exist in the secondary
select buffer if the cell was previously moved or copied, and
an attempt to do another move or copy will clear the secondary
select buffer, encounter the deleted cell, and crash the program.
2024-11-26 13:43:27 -05:00
Darryl L. Miles 9ca8697659 strings.h: add #include required when strict
Due to use of strcasecmp() or similar C API.

Maybe HAVE_STRINGS_H is needed ?  If so which platforms needs this ?

clang18 default warning cleanup (strict)
2024-10-09 21:22:37 -04:00
Darryl L. Miles 4460c5f1f5 DBio.c: warning: 'sscanf' may overflow; destination buffer in argument ...
DBio.c:2358:21: warning: 'sscanf' may overflow; destination buffer in
  argument 4 has size 2048, but the corresponding specifier may require
  size 2049

clang18 default warning cleanup [-Wfortify-source]
2024-10-09 21:22:37 -04:00
Darryl L. Miles b723dc15d8 DBio.c:1604:65: warning: too many arguments in call to 'dbReadOpen'
DBio.c:1604:52: warning: expression which evaluates to zero treated as
 a null pointer constant of type 'int *' [-Wnon-literal-null-conversion]

DBOpenOnly() function only has one use which always passed name==NULL.

clang18 default warning cleanup
2024-10-09 21:17:28 -04:00
Darryl L. Miles 59bfe8f6c0 DBcellsrch.c:2249:22: warning: too many arguments in call to 'dbMovePlane'
clang18 default warning cleanup
2024-10-09 21:17:28 -04:00
Darryl L. Miles 6cdb9ad167 36 x warning: suggest parentheses around assignment used as truth value
bpMain.c:265:11: warning: suggest parentheses around assignment used as truth value
CmdSubrs.c:413:12: warning: suggest parentheses around assignment used as truth value
CmdSubrs.c:759:13: warning: suggest parentheses around assignment used as truth value
CmdFI.c:1600:12: warning: suggest parentheses around assignment used as truth value
DBcell.c:109:12: warning: suggest parentheses around assignment used as truth value
DBcellname.c:2512:9: warning: suggest parentheses around assignment used as truth value
DBcellsrch.c:95:12: warning: suggest parentheses around assignment used as truth value
DBio.c:3998:9: warning: suggest parentheses around assignment used as truth value
DBlabel2.c:228:9: warning: suggest parentheses around assignment used as truth value
DBWelement.c:195:12: warning: suggest parentheses around assignment used as truth value
DBWelement.c:197:13: warning: suggest parentheses around assignment used as truth value
DBWelement.c:295:12: warning: suggest parentheses around assignment used as truth value
DBWelement.c:297:13: warning: suggest parentheses around assignment used as truth value
DBWelement.c:637:12: warning: suggest parentheses around assignment used as truth value
DBWelement.c:639:13: warning: suggest parentheses around assignment used as truth value
DBWelement.c:679:12: warning: suggest parentheses around assignment used as truth value
DBWelement.c:681:13: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1219:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1368:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1471:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1543:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1676:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1772:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:1919:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2099:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2324:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2713:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2830:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:2944:17: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3097:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3144:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3181:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3215:9: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3227:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3261:21: warning: suggest parentheses around assignment used as truth value
DRCtech.c:3459:17: 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 d94cd72538 37 x warning: array subscript has type 'char'
Compiler is expressing range concern with the warning mitigated by using
unsigned C array offsets.  This also draws attention to the range concern
when reading the code and making changes.

DBundo.c:263:45: warning: array subscript has type 'char'
DBundo.c:279:49: warning: array subscript has type 'char'
DBundo.c:317:52: warning: array subscript has type 'char'
DBundo.c:318:64: warning: array subscript has type 'char'
DBundo.c:324:52: warning: array subscript has type 'char'
DBundo.c:325:64: warning: array subscript has type 'char'
DBundo.c:329:50: warning: array subscript has type 'char'
DBundo.c:330:58: warning: array subscript has type 'char'
DBundo.c:338:52: warning: array subscript has type 'char'
DBundo.c:339:64: warning: array subscript has type 'char'
DBundo.c:345:52: warning: array subscript has type 'char'
DBundo.c:346:64: warning: array subscript has type 'char'
DBundo.c:350:50: warning: array subscript has type 'char'
DBundo.c:351:58: warning: array subscript has type 'char'
DBundo.c:371:52: warning: array subscript has type 'char'
DBundo.c:372:64: warning: array subscript has type 'char'
DBundo.c:378:52: warning: array subscript has type 'char'
DBundo.c:379:64: warning: array subscript has type 'char'
DBundo.c:383:50: warning: array subscript has type 'char'
DBundo.c:384:58: warning: array subscript has type 'char'
DBundo.c:392:52: warning: array subscript has type 'char'
DBundo.c:393:57: warning: array subscript has type 'char'
DBundo.c:399:52: warning: array subscript has type 'char'
DBundo.c:400:57: warning: array subscript has type 'char'
DBundo.c:403:53: warning: array subscript has type 'char'
DBundo.c:407:50: warning: array subscript has type 'char'
DBundo.c:408:58: warning: array subscript has type 'char'
EFbuild.c:1048:32: warning: array subscript has type 'char'
EFbuild.c:1056:32: warning: array subscript has type 'char'
ExtBasic.c:2358:43: warning: array subscript has type 'char'
ExtBasic.c:2493:43: warning: array subscript has type 'char'
ExtBasic.c:2519:43: warning: array subscript has type 'char'
ExtBasic.c:2644:43: warning: array subscript has type 'char'
ExtBasic.c:2678:43: warning: array subscript has type 'char'
ResPrint.c:143:43: warning: array subscript has type 'char'
plotRutils.c:713:34: warning: array subscript has type 'char'
plotRutils.c:786:29: warning: array subscript has type 'char'

GCC14 -Wall cleanup series [-Wchar-subscripts]
2024-10-09 21:12:55 -04:00
Darryl L. Miles 9225fa6cf1 4 x warning: suggest explicit braces to avoid ambiguous 'else'
Give compiler the extra braces it recommends.

DBio.c edited as my original change was caught out by the incorrect
indention of the 'else' keyword and my modification would have caused a
NULL deref.   Exactly the kind of issue this warning is trying to prevent.

CmdTZ.c:417:20: warning: suggest explicit braces to avoid ambiguous 'else'
DBio.c:1422:12: warning: suggest explicit braces to avoid ambiguous 'else'
DBpaint2.c:285:12: warning: suggest explicit braces to avoid ambiguous 'else'
DBpaint2.c:384:12: warning: suggest explicit braces to avoid ambiguous 'else'

GCC14 -Wall cleanup series [-Wdangling-else]
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 4ea0f6a9b7 DBcellcopy.c: fix warning: self-comparison always evaluates to false
Looks like a straighforward logic bug from a recent (2023) change.

GCC14 -Wall cleanup series [-Wtautological-compare]
2024-10-09 20:50:00 -04:00
Darryl L. Miles 63256f1a44 DBio.c: resolve warnings and use snprintf()
GCC14 loud default warnings series [-Wformat-overflow=]
2024-10-09 20:39:12 -04:00
Darryl L. Miles 23930909b1 database/DBio.c: error: assignment to 'char *' from 'ClientData'
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 8994a68e61 DBPropGet(): error: assignment to 'char *' from 'ClientData'
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 0a4e2a5a27 HashGetValue: warning: comparison between pointer and integer
GCC14 --without-tk --without-tcl
Related issue: https://github.com/RTimothyEdwards/magic/issues/323
2024-10-09 20:35:19 -04:00
Tim Edwards e2c3eb3e20 Corrected the previous commit, which did not fix the problem that
it claimed to fix, but caused an incorrect DRC maxwidth check
instead.  The problem appears to be correctly resolved now.
Also:  Tracked down a recently-introduced minor issue in which
the interactive DRC stops running after issuing "drc check" and
does not resume until another key or mouse even occurs.  This
turned out to be caused by the work on the "logcommands" command,
which should have used "*bypass" before "logcommands suspend"
and "logcommands resume", since the "*bypass" indicates that
the command has no impact on layout and should not interrupt
the DRC checker.
2024-10-01 21:14:12 -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 e119188f23 fix: findUse can return NULL crash
The main cause of the crash was the path for UNDO_CELL_PLACE this was
trigged by performing a number of cell create/move operations (unknown
exactly what sequence).  Then a large number of "undo" operations.

There is an ASSERT in findUse() but that does not seem built into the
release (or debug CFLAGS=-g3) builds.
2024-10-01 12:43:27 -04:00
Darryl L. Miles 973c9a4d1a database/DBio.c read of variable before initialization
Due to FEOF condition and handling it is possible local variable 'c' is not
initialized before being read and compared.

SonarCloud retails
DBio.c:3049 The left operand of '==' is a garbage value
https://sonarcloud.io/project/issues?open=AZJB16rxNGfDNup0Ribf&id=dlmiles_magic
2024-10-01 12:36:13 -04:00
Darryl Miles 1fb82e7225 database/DBtiles.c: Multiplication result converted to larger type
Fix code scanning alert no. 30: Multiplication result converted to larger type (#55)

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 499ac84ac0 database/DBio.c: Redundant null check due to previous dereference
Fix code scanning alert no. 132: Redundant null check due to previous dereference (#39)

* Update DBio.c

* AI wanted to move guard 'pathptr != NULL' up to 1953, but it is assigned to guaranteed non-null in every assignment above and only incremented or dereferenced.

---------

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 82aa62e65d database/DBcellsrch.c: Wrong type of arguments to formatting function
Fix code scanning alert no. 66: Wrong type of arguments to formatting function (#33)

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 573e59da44 database/DBcellname.c: Call to function with fewer arguments than declared parameters
Fix code scanning alert no. 10: Call to function with fewer arguments than declared parameters (#14)

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 a5f7cbd597 database/DBcellcopy.c: Call to function with fewer arguments than declared parameters
Fix code scanning alert no. 9: Call to function with fewer arguments than declared parameters (#15)

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 886a0212e8 database/DBtech.c: Incorrect return-value check for a 'scanf'-like function
Fix code scanning alert no. 135: Incorrect return-value check for a 'scanf'-like function (#12)

* Create codeql.yml

* Fix code scanning alert no. 135: 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>

---------

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 L. Miles 881115a856 database/DBio.c: Fix MAGIC_WRAPPER #endif to fix CI WASM build
Misplaced #endif causing the build to break when option enabled
error introduced in 3dc5018

Related commits:

commit 68a088943f
Date:   Tue Sep 12 11:12:00 2023 -0400

commit 3dc5018af4 (tag: 8.3.477)
Date:   Fri May 3 21:43:27 2024 -0400
2024-09-30 23:00:00 +01:00
Tim Edwards 427547c927 Changed the behavior of renaming conflicting cells from
"<name>#<num>" to "<name>__<num>", because the use of "#" is
considered illegal for cell names in GDS.
2024-09-15 17:33:51 -04:00
Tim Edwards 81b5ac2079 Added two checks when loading a file to determine if two cells are
the same:  (1) If the inodes of the filename are the same, then the
cells are the same.  This avoids treating symbolic links as
different paths with different files;  (2) If both layouts are in
git repositories and the git repository commit hashes are the same,
then the cells are considered to be the same.  This allows projects
to be cloned into other projects as dependencies and used in
multiple places without magic treating them as different layouts.
2024-06-13 15:39:27 -04:00
Tim Edwards e9db9ecbc9 Another correction that avoids a crash condition when attempting
to do an instance array resizing on an uneditable cell.
2024-05-25 21:15:01 -04:00
Tim Edwards cf5fd867f4 Corrected another error related to read-only views in which magic crashes when
attempting to place a generated cell in the layout, as pointed out by Mark Martin
in github Issue #309.
2024-05-24 12:43:36 -04:00
Tim Edwards 9dec47c9b2 Corrected a fairly long-standing error in which the MASKHINTS_ values
in the .mag file "properties" list are not handled as being in
database units during .mag file reading and writing (although they
do track internally), making them subject to being scaled incorrectly
and change between a read and a write.  Thanks to Sylvain Munaut for
identifying the problem.
2024-05-10 13:05:06 -04:00
Tim Edwards ca99d0b76a Altered the behavior of handling labels when a layer under a label
is erased.  In cases where magic would previously unattach the
label from the material and attach it to "space", now magic will
instead adjust the size of the label to stay entirely on the
material.  That avoids a common error of losing label or port
connections when the material is trimmed back.  Thanks to Philipp
Guhring for suggesting this implementation (github issue #305).
2024-05-04 21:12:55 -04:00