Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcdi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
libcdi
Commits
4c48a83f
Commit
4c48a83f
authored
2 years ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
Replaced sprintf() by snprintf().
parent
f65a1ad0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!34
Version 2.2.0
Pipeline
#23156
failed
1 month ago
Stage: external
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/table.c
+23
-28
23 additions, 28 deletions
src/table.c
with
23 additions
and
28 deletions
src/table.c
+
23
−
28
View file @
4c48a83f
...
...
@@ -107,7 +107,7 @@ parTableFinalize(void)
for
(
int
tableID
=
0
;
tableID
<
MAX_TABLE
;
++
tableID
)
if
(
parTable
[
tableID
].
used
)
{
int
npars
=
parTable
[
tableID
].
npars
;
const
int
npars
=
parTable
[
tableID
].
npars
;
for
(
int
item
=
0
;
item
<
npars
;
++
item
)
{
if
(
parTable
[
tableID
].
pars
[
item
].
dupflags
&
TABLE_DUP_NAME
)
Free
((
void
*
)
parTable
[
tableID
].
pars
[
item
].
name
);
...
...
@@ -161,7 +161,7 @@ decodeForm1(char *pline, char *name, char *longname, char *units)
{
char
*
pstart
,
*
pend
;
/
*
FIXME: parse success isn't verified
*/
/
/
FIXME: parse success isn't verified
/* long level = */
strtol
(
pline
,
&
pline
,
10
);
while
(
isspace
((
int
)
*
pline
))
pline
++
;
...
...
@@ -178,10 +178,10 @@ decodeForm1(char *pline, char *name, char *longname, char *units)
if
(
pline
[
0
]
==
0
)
return
0
;
/
*
Format 1 : code name add mult longname [units]
*/
/
*
FIXME: successful parse isn't verified
*/
/
/
Format 1 : code name add mult longname [units]
/
/
FIXME: successful parse isn't verified
/* double add = */
strtod
(
pline
,
&
pline
);
/
*
FIXME: successful parse isn't verified
*/
/
/
FIXME: successful parse isn't verified
/* double mult = */
strtod
(
pline
,
&
pline
);
while
(
isspace
((
int
)
*
pline
))
pline
++
;
...
...
@@ -366,7 +366,7 @@ tableRead(const char *tablefile)
if
(
err
)
continue
;
if
(
name
[
0
]
==
0
)
sprintf
(
name
,
"var%d"
,
id
);
if
(
name
[
0
]
==
0
)
s
n
printf
(
name
,
sizeof
(
name
),
"var%d"
,
id
);
tableDefEntry
(
tableID
,
id
,
ltype
,
name
,
longname
,
units
);
}
...
...
@@ -396,8 +396,8 @@ tableFromEnv(int modelID, int tablenum)
if
(
tablenum
)
tablenameLen
+=
(
size_t
)
(
sprintf
(
tablename
+
tablenameLen
,
"_%03d"
,
tablenum
));
size_t
lenp
=
0
,
lenf
=
tablenameLen
;
if
(
tablePath
)
lenp
=
strlen
(
tablePath
);
/
*
if (tablePath) printf("tablePath = %s\n", tablePath);
*/
/
*
if (tablename) printf("tableName = %s\n", tablename);
*/
/
/
if (tablePath) printf("tablePath = %s\n", tablePath);
/
/
if (tablename) printf("tableName = %s\n", tablename);
char
*
tablefile
=
(
char
*
)
Malloc
(
lenp
+
lenf
+
3
);
if
(
tablePath
)
{
...
...
@@ -407,7 +407,7 @@ tableFromEnv(int modelID, int tablenum)
else
tablefile
[
0
]
=
'\0'
;
strcat
(
tablefile
,
tablename
);
/
*
if (tablefile) printf("tableFile = %s\n", tablefile);
*/
/
/
if (tablefile) printf("tableFile = %s\n", tablefile);
int
tableID
=
tableRead
(
tablefile
);
if
(
tableID
!=
CDI_UNDEFID
)
...
...
@@ -415,7 +415,7 @@ tableFromEnv(int modelID, int tablenum)
tableDefModelID
(
tableID
,
modelID
);
tableDefNum
(
tableID
,
tablenum
);
}
/
*
printf("tableID = %d %s\n", tableID, tablefile);
*/
/
/
printf("tableID = %d %s\n", tableID, tablefile);
Free
(
tablefile
);
return
tableID
;
...
...
@@ -502,10 +502,7 @@ tableDef(int modelID, int tablenum, const char *tablename)
int
tableID
=
CDI_UNDEFID
;
if
(
!
ParTableInit
)
parTableInit
();
/*
if ( ! (modelID == CDI_UNDEFID && tablenum == 0) )
tableID = tableInq(modelID, tablenum, tablename);
*/
// if (!(modelID == CDI_UNDEFID && tablenum == 0)) tableID = tableInq(modelID, tablenum, tablename);
if
(
tableID
==
CDI_UNDEFID
)
{
tableID
=
tableNewEntry
();
...
...
@@ -595,31 +592,30 @@ tableWrite(const char *ptfile, int tableID)
FILE
*
ptfp
=
fopen
(
ptfile
,
"w"
);
int
npars
=
parTable
[
tableID
].
npars
;
const
int
npars
=
parTable
[
tableID
].
npars
;
for
(
int
item
=
0
;
item
<
npars
;
item
++
)
{
if
(
parTable
[
tableID
].
pars
[
item
].
name
)
{
size_t
lenname
=
strlen
(
parTable
[
tableID
].
pars
[
item
].
name
);
const
size_t
lenname
=
strlen
(
parTable
[
tableID
].
pars
[
item
].
name
);
if
(
lenname
>
maxname
)
maxname
=
lenname
;
}
if
(
parTable
[
tableID
].
pars
[
item
].
longname
)
{
size_t
lenlname
=
strlen
(
parTable
[
tableID
].
pars
[
item
].
longname
);
const
size_t
lenlname
=
strlen
(
parTable
[
tableID
].
pars
[
item
].
longname
);
if
(
lenlname
>
maxlname
)
maxlname
=
lenlname
;
}
if
(
parTable
[
tableID
].
pars
[
item
].
units
)
{
size_t
lenunits
=
strlen
(
parTable
[
tableID
].
pars
[
item
].
units
);
const
size_t
lenunits
=
strlen
(
parTable
[
tableID
].
pars
[
item
].
units
);
if
(
lenunits
>
maxunits
)
maxunits
=
lenunits
;
}
}
int
tablenum
=
tableInqNum
(
tableID
);
int
modelID
=
parTable
[
tableID
].
modelID
;
const
int
tablenum
=
tableInqNum
(
tableID
);
const
int
modelID
=
parTable
[
tableID
].
modelID
;
if
(
modelID
!=
CDI_UNDEFID
)
{
modelnameptr
=
modelInqNamePtr
(
modelID
);
...
...
@@ -680,25 +676,24 @@ tableFWriteC(FILE *ptfp, int tableID)
partabCheckID
(
tableID
);
int
npars
=
parTable
[
tableID
].
npars
;
const
int
npars
=
parTable
[
tableID
].
npars
;
for
(
int
item
=
0
;
item
<
npars
;
item
++
)
{
if
(
parTable
[
tableID
].
pars
[
item
].
name
)
{
size_t
lenname
=
strlen
(
parTable
[
tableID
].
pars
[
item
].
name
);
const
size_t
lenname
=
strlen
(
parTable
[
tableID
].
pars
[
item
].
name
);
if
(
lenname
>
maxname
)
maxname
=
lenname
;
}
if
(
parTable
[
tableID
].
pars
[
item
].
longname
)
{
size_t
lenlname
=
strlen
(
parTable
[
tableID
].
pars
[
item
].
longname
);
const
size_t
lenlname
=
strlen
(
parTable
[
tableID
].
pars
[
item
].
longname
);
if
(
lenlname
>
maxlname
)
maxlname
=
lenlname
;
}
if
(
parTable
[
tableID
].
pars
[
item
].
units
)
{
size_t
lenunits
=
strlen
(
parTable
[
tableID
].
pars
[
item
].
units
);
const
size_t
lenunits
=
strlen
(
parTable
[
tableID
].
pars
[
item
].
units
);
if
(
lenunits
>
maxunits
)
maxunits
=
lenunits
;
}
}
...
...
@@ -738,7 +733,7 @@ tableInqEntry(int tableID, int id, int ltype, char *name, char *longname, char *
if
(
tableID
!=
CDI_UNDEFID
)
{
int
npars
=
parTable
[
tableID
].
npars
;
const
int
npars
=
parTable
[
tableID
].
npars
;
for
(
int
item
=
0
;
item
<
npars
;
item
++
)
{
if
(
parTable
[
tableID
].
pars
[
item
].
id
==
id
...
...
@@ -761,7 +756,7 @@ tableInqParCode(int tableID, char *varname, int *code)
if
(
tableID
!=
CDI_UNDEFID
&&
varname
!=
NULL
)
{
int
npars
=
parTable
[
tableID
].
npars
;
const
int
npars
=
parTable
[
tableID
].
npars
;
for
(
int
item
=
0
;
item
<
npars
;
item
++
)
{
if
(
parTable
[
tableID
].
pars
[
item
].
name
&&
strcmp
(
parTable
[
tableID
].
pars
[
item
].
name
,
varname
)
==
0
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment