Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K&R utils/** and const-correctness (part 1) #352

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
24a777b
utils/strdup.c: StrDup() and mode constifiy impl
dlmiles Oct 12, 2024
48fd73b
util/hash.[ch]: const hash 'key' for API and internal type
dlmiles Oct 4, 2024
0848ea7
geometry.h: constify global wellknown Geometry data values
dlmiles Oct 12, 2024
2182e2a
utils/lookup*.c: constify the API
dlmiles Oct 10, 2024
f9d78b6
LookupStructFull() constify call-site
dlmiles Oct 10, 2024
bd62b03
geometry.c: constify and add prototypes
dlmiles Oct 12, 2024
d342dc8
GeoDisjoint() unify return type of callback to bool
dlmiles Oct 12, 2024
bfa2e58
LookupStruct() constify call-site
dlmiles Oct 10, 2024
df5bb36
LookupFull() constify call-site
dlmiles Oct 10, 2024
a5fc067
Lookup() constify call-site with Tcl_SetResult()
dlmiles Oct 10, 2024
1ade5db
Lookup() constify WindGetCommandTable() returns 'const'
dlmiles Oct 10, 2024
d77e350
windows/windCmdNR.c: Lookup() constify call-site (extern data)
dlmiles Oct 10, 2024
1cbbd95
Lookup() constify call-site
dlmiles Oct 10, 2024
8b6dac7
extract/ExtBasic.c: Lookup() constify call-site
dlmiles Oct 10, 2024
810ed77
Lookup() constify call-site
dlmiles Oct 10, 2024
dbf39c5
utils/match.c constify Match() and add prototype
dlmiles Oct 10, 2024
138fc21
args.c: ArgStr() constify and add prototype
dlmiles Oct 12, 2024
5af853a
PaCheckCompressed() removed API quirkiness
dlmiles Oct 12, 2024
cf1e8d7
PaCheckCompressed() constify implementation
dlmiles Oct 12, 2024
dc1e457
path.c: PaAppend() constify and add prototype
dlmiles Oct 12, 2024
21f9f4d
path.c: PaExpand() constify and add prototype
dlmiles Oct 12, 2024
ac123fa
path.c: nextName() constify and add prototype
dlmiles Oct 12, 2024
e683388
path.c: PaLockZOpen() constify and add prototype
dlmiles Oct 12, 2024
280a9dd
path.c: PaLockOpen() constify and add prototype
dlmiles Oct 12, 2024
89366ac
path.c: PaZOpen() constify and add prototype
dlmiles Oct 12, 2024
cf96971
path.c: PaOpen() constify and add prototype
dlmiles Oct 12, 2024
4c71191
path.c: PaSubsWD() constify and no prototype exists
dlmiles Oct 12, 2024
a7112dd
path.c: PaEnum() constify and add prototype
dlmiles Oct 12, 2024
3b5c7e5
database/DBio.c: PaExpand() constify update call-site
dlmiles Oct 12, 2024
6ec1e2b
utils.h: Wait()/WaitPid() add prototype
dlmiles Oct 12, 2024
c3b2635
port.c: MagAtof() constify and add prototype
dlmiles Oct 12, 2024
21a9bb8
set.c: SetNoisyInt() constify and add prototype
dlmiles Oct 12, 2024
4034b33
set.c: SetNoisyDI() constify and add prototype
dlmiles Oct 12, 2024
81e5f87
set.c: SetNoisyBool() constify and add prototype
dlmiles Oct 12, 2024
7e9c3a7
util/lookup*.c: fix integer pointer arithmetic not using pointertype
dlmiles Oct 10, 2024
a849ffd
irouter/irCommand.c: fix SetNoisyDI() usage
dlmiles Oct 12, 2024
227484d
util/hash.c: fix use after free (not quite)
dlmiles Oct 4, 2024
d43be3c
dbwind/DBWelement.c: constify args to AppendFlag/AppendString
dlmiles Oct 21, 2024
730f2d4
extflat/EFdef.c: hash constify freeMalloc() constness cast
dlmiles Oct 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cif/CIFrdutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1466,9 +1466,9 @@ cifParseComment()
* ----------------------------------------------------------------------------
*/

Transform *
const Transform *
CIFDirectionToTrans(point)
Point *point; /* Direction vector from origin. */
const Point *point; /* Direction vector from origin. */
{
if ((point->p_x != 0) && (point->p_y == 0))
{
Expand Down
2 changes: 1 addition & 1 deletion cif/CIFread.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ extern void CIFSkipToSemi(), CIFSkipSep(), CIFSkipBlanks();
extern void CIFFreePath(), CIFCleanPath();
extern void CIFReadCellInit(), CIFReadCellCleanup();
extern LinkedRect *CIFPolyToRects();
extern Transform *CIFDirectionToTrans();
extern const Transform *CIFDirectionToTrans(const Point *point);
extern int CIFReadNameToType();

/* Variable argument procedures require complete prototype */
Expand Down
2 changes: 1 addition & 1 deletion cmwind/CMWcmmnds.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ cmwPushbutton(w, cmd)
TxCommand *cmd;
{
int button;
static char *cmwButton[] = {"left", "middle", "right", NULL};
static const char * const cmwButton[] = {"left", "middle", "right", NULL};

if (cmd->tx_argc != 2)
{
Expand Down
8 changes: 4 additions & 4 deletions commands/CmdAB.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ CmdArray(w, cmd)
MagWindow *w;
TxCommand *cmd;
{
static char *cmdArrayOption[] = {
static const char * const cmdArrayOption[] = {
"count [[xlo] xhi [ylo] yhi] array subcells",
"width [value] set or return array x-spacing",
"height [value] set or return array y-spacing",
Expand All @@ -144,7 +144,7 @@ CmdArray(w, cmd)
NULL
};

char **msg;
const char * const *msg;
int option, locargc, argstart;
bool doList = FALSE;
ArrayInfo a;
Expand Down Expand Up @@ -597,7 +597,7 @@ CmdBox(w, cmd)
MagWindow *w;
TxCommand *cmd;
{
static char *cmdBoxOption[] = {
static const char * const cmdBoxOption[] = {
"width [value] set or return box width",
"height [value] set or return box height",
"size [width height] set or return box size",
Expand Down Expand Up @@ -626,7 +626,7 @@ CmdBox(w, cmd)
bool needBox = TRUE; /* require that box be defined */
bool refEdit = FALSE; /* referenced to edit cell coordinates */
bool cursorRef = FALSE; /* reference position is the cursor */
char **msg;
const char * const *msg;

argc = cmd->tx_argc;
if (argc > 7) goto badusage;
Expand Down
43 changes: 23 additions & 20 deletions commands/CmdCD.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ CmdCalma(w, cmd)
TxCommand *cmd;
{
int option, ext, value;
char **msg, *namep, *dotptr;
const char * const *msg;
char *namep, *dotptr;
char writeMode[3];
CellDef *rootDef;
FILETYPE f;
Expand All @@ -139,14 +140,14 @@ CmdCalma(w, cmd)
gzFile fz;
#endif

static char *gdsExts[] = {".gds", ".gds.gz", ".gds2", ".strm", "", NULL};
static char *cmdCalmaYesNo[] = {
static const char * const gdsExts[] = {".gds", ".gds.gz", ".gds2", ".strm", "", NULL};
static const char * const cmdCalmaYesNo[] = {
"no", "false", "off", "0", "yes", "true", "on", "1", 0 };
static char *cmdCalmaAllowDisallow[] = {"disallow", "0", "allow", "1", 0};
static char *cmdCalmaPolygonType[] = {"none", "temporary", "keep", 0};
static char *cmdCalmaWarnOptions[] = { "default", "none", "align",
static const char * const cmdCalmaAllowDisallow[] = {"disallow", "0", "allow", "1", 0};
static const char * const cmdCalmaPolygonType[] = {"none", "temporary", "keep", 0};
static const char * const cmdCalmaWarnOptions[] = { "default", "none", "align",
"limit", "redirect", "help", 0 };
static char *cmdCalmaOption[] =
static const char * const cmdCalmaOption[] =
{
"help print this help information",
"abstract [allow|disallow]\n"
Expand Down Expand Up @@ -1115,7 +1116,7 @@ CmdCellname(w, cmd)
void (*func)();
CellDef *newDef, *cellDef;

static char *cmdCellOption[] =
static const char * const cmdCellOption[] =
{
"children list children of selected or named cell",
"parents list parents of selected or named cell",
Expand Down Expand Up @@ -1151,7 +1152,7 @@ CmdCellname(w, cmd)
IDX_ORIENTATION, IDX_RENAME, IDX_READWRITE,
IDX_MODIFIED } optionType;

static char *cmdCellnameYesNo[] = {
static const char * const cmdCellnameYesNo[] = {
"no", "false", "off", "0", "yes", "true", "on", "1", 0 };

if (strstr(cmd->tx_argv[0], "in"))
Expand Down Expand Up @@ -1715,7 +1716,8 @@ CmdCif(w, cmd)
TxCommand *cmd;
{
int option, yesno;
char **msg, *namep;
const char * const *msg;
char *namep;
CellDef *rootDef, *paintDef;
Rect box;
TileType layer;
Expand All @@ -1730,11 +1732,11 @@ CmdCif(w, cmd)
int argshift;
char **argv = cmd->tx_argv;

static char *cmdCifWarnOptions[] = { "default", "none", "align",
static const char * const cmdCifWarnOptions[] = { "default", "none", "align",
"limit", "redirect", "help", 0 };
static char *cmdCifYesNo[] = { "no", "yes", 0 };
static char *cmdCifInOut[] = { "input", "output", 0 };
static char *cmdCifOption[] =
static const char * const cmdCifYesNo[] = { "no", "yes", 0 };
static const char * const cmdCifInOut[] = { "input", "output", 0 };
static const char * const cmdCifOption[] =
{
"*array layer display CIF layer under box (array only)",
"*hier layer display CIF layer under box (hier only)",
Expand Down Expand Up @@ -3686,7 +3688,7 @@ CmdCrash(w, cmd)
{
int option = -1;
char *filename = NULL;
static char *cmdCrashOpt[] = {"save", "recover", 0};
static const char * const cmdCrashOpt[] = {"save", "recover", 0};

if (cmd->tx_argc > 3)
TxError("Usage: %s save|recover [filename]\n", cmd->tx_argv[0]);
Expand Down Expand Up @@ -3994,7 +3996,7 @@ CmdDrc(w, cmd)
CellDef * rootDef;
Transform trans;
MagWindow * window;
char **msg;
const char * const *msg;
bool wizardHelp;
bool incremental;
bool doforall = FALSE;
Expand All @@ -4010,7 +4012,7 @@ CmdDrc(w, cmd)
Tcl_Obj *lobj;
#endif

static char *cmdDrcOption[] =
static const char * const cmdDrcOption[] =
{
"*flatcheck check box area by flattening",
"*halo [d] limit error checking to areas of d units",
Expand Down Expand Up @@ -4819,7 +4821,8 @@ cmdDumpParseArgs(cmdName, w, cmd, dummy, scx)
CellDef *def, *rootDef, *editDef;
bool hasChild, hasRoot, hasTrans;
Rect rootBox, bbox;
Transform *tx_cell, trans_cell;
const Transform *tx_cell;
Transform trans_cell;
char **av;
char *cellnameptr, *fullpathname;
int ac, clen;
Expand Down Expand Up @@ -4961,10 +4964,10 @@ cmdDumpParseArgs(cmdName, w, cmd, dummy, scx)
hasChild = hasRoot = hasTrans = FALSE;
while (ac > 0)
{
static char *kwdNames[] = { "child", "parent", "0", "90", "180", "270",
static const char * const kwdNames[] = { "child", "parent", "0", "90", "180", "270",
"v", "0v", "90v", "180v", "270v",
"h", "0h", "90h", "180h", "270h", 0 };
static char *refPointNames[] = { "ll", "lr", "ul", "ur", 0 };
static const char * const refPointNames[] = { "ll", "lr", "ul", "ur", 0 };
Label *lab;
int n,p;

Expand Down
21 changes: 11 additions & 10 deletions commands/CmdE.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,14 @@ CmdElement(w, cmd)
{

int option, type;
char **msg;
const char * const *msg;
Rect area;
int style;
CellDef *def;
CellUse *use;
bool getopt;

static char *cmdElementOption[] = {
static const char * const cmdElementOption[] = {
"add create a new element",
"delete delete an existing element",
"configure configure or query an existing element",
Expand All @@ -328,14 +328,14 @@ CmdElement(w, cmd)
NULL
};

static char *cmdElementType[] = {
static const char * const cmdElementType[] = {
"line name style x1 y1 x2 y2",
"rectangle name style llx lly urx ury",
"text name style cx cy label",
NULL
};

static char *cmdConfigureType[] = {
static const char * const cmdConfigureType[] = {
"text get (or) replace <string>",
"style get (or) add <style> (or) remove <style>",
"position get (or) <point> (or) <rect>",
Expand Down Expand Up @@ -945,7 +945,8 @@ CmdExtract(w, cmd)
MagWindow *w;
TxCommand *cmd;
{
char **msg, *namep, *arg;
const char * const *msg;
char *namep, *arg;
int option, warn, len, n, all;
int dist;
bool no;
Expand All @@ -957,15 +958,15 @@ CmdExtract(w, cmd)
int argc = cmd->tx_argc;
char **argv = cmd->tx_argv;

static char *cmdExtWarn[] =
static const char * const cmdExtWarn[] =
{
"all enable all warnings",
"dup warn when different nodes have the same name",
"fets warn about badly constructed fets",
"labels warn when subcell nodes are unlabelled",
NULL
};
static char *cmdExtOption[] =
static const char * const cmdExtOption[] =
{
"adjust compensate R and C hierarchically",
"all all options",
Expand All @@ -978,7 +979,7 @@ CmdExtract(w, cmd)
"aliases output all net name aliases",
NULL
};
static char *cmdExtLength[] =
static const char * const cmdExtLength[] =
{
"clear clear the driver and receiver tables",
"driver termName(s) identify a driving (output) terminal",
Expand All @@ -988,15 +989,15 @@ CmdExtract(w, cmd)

/* These must match definitions EXT_UNIQ_* in extract/extract.h: */

static char *cmdExtUniq[] =
static const char * const cmdExtUniq[] =
{
"all extract matching labels as unique nodes",
"# extract tagged labels as unique nodes",
"noports ignore ports when making labels unique",
"notopports ignore top-level ports when making labels unique",
NULL
};
static char *cmdExtCmd[] =
static const char * const cmdExtCmd[] =
{
"all extract root cell and all its children",
"cell name extract selected cell into file \"name\"",
Expand Down
11 changes: 6 additions & 5 deletions commands/CmdFI.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ CmdFeedback(w, cmd)
MagWindow *w;
TxCommand *cmd;
{
static char *cmdFeedbackOptions[] =
static const char * const cmdFeedbackOptions[] =
{
"add text [style] [points...] create new feedback area over box",
"clear [substring] clear all or selected feedback info",
Expand All @@ -161,11 +161,11 @@ CmdFeedback(w, cmd)
"why print all feedback messages under box",
NULL
};
static char *cmdFeedbackStyleNames[] =
static const char * const cmdFeedbackStyleNames[] =
{
"dotted", "medium", "outline", "pale", "solid", NULL
};
static int cmdFeedbackStyles[] =
static const int cmdFeedbackStyles[] =
{
STYLE_DOTTEDHIGHLIGHTS, STYLE_MEDIUMHIGHLIGHTS,
STYLE_OUTLINEHIGHLIGHTS, STYLE_PALEHIGHLIGHTS,
Expand All @@ -176,7 +176,8 @@ CmdFeedback(w, cmd)
*/
int option, i, style, pstart;
Rect box, r;
char *text, **msg;
char *text;
const char * const *msg;
CellDef *rootDef;
HashTable table;
HashEntry *h;
Expand Down Expand Up @@ -1259,7 +1260,7 @@ CmdGrid(w, cmd)
int xSpacing, ySpacing, xOrig, yOrig, multiple;
DBWclientRec *crec;
char *boxvalues;
static char *cmdGridOptions[] =
static const char * const cmdGridOptions[] =
{
"box [values] report the box representing the user grid",
"help print this message",
Expand Down
Loading