Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC DEL 1ns 4cha
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FMC DEL 1ns 4cha
Commits
95ed6ec8
Commit
95ed6ec8
authored
Nov 14, 2022
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw: apply some flawfinder suggestions
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
20c8e332
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
35 additions
and
29 deletions
+35
-29
fdelay-init.c
software/lib/fdelay-init.c
+1
-1
fdelay-lib.h
software/lib/fdelay-lib.h
+2
-2
fdelay-output.c
software/lib/fdelay-output.c
+18
-18
fdelay-tdc.c
software/lib/fdelay-tdc.c
+1
-1
fmc-fdelay-calibration.c
software/tools/fmc-fdelay-calibration.c
+1
-1
fmc-fdelay-pulse.c
software/tools/fmc-fdelay-pulse.c
+7
-1
tools-util.c
software/tools/tools-util.c
+5
-5
No files found.
software/lib/fdelay-init.c
View file @
95ed6ec8
...
...
@@ -96,7 +96,7 @@ struct fdelay_board *fdelay_open(int dev_id)
goto
err_stat_d
;
if
(
!
S_ISCHR
(
sb
.
st_mode
))
goto
err_stat_d
;
b
->
devbase
=
strndup
(
path
,
str
len
(
path
)
-
strlen
(
"-0-0-ctrl"
));
b
->
devbase
=
strndup
(
path
,
str
nlen
(
path
,
sizeof
(
path
)
)
-
strlen
(
"-0-0-ctrl"
));
ret
=
fdelay_sysfs_get
(
b
,
"version"
,
&
v
);
if
(
ret
)
...
...
software/lib/fdelay-lib.h
View file @
95ed6ec8
...
...
@@ -198,7 +198,7 @@ static inline int fdelay_sysfs_get(struct __fdelay_board *b, char *name,
{
char
pathname
[
128
];
s
printf
(
pathname
,
"%s/%s"
,
b
->
sysbase
,
name
);
s
nprintf
(
pathname
,
sizeof
(
pathname
)
,
"%s/%s"
,
b
->
sysbase
,
name
);
return
__fdelay_sysfs_get
(
pathname
,
resp
);
}
...
...
@@ -207,7 +207,7 @@ static inline int fdelay_sysfs_set(struct __fdelay_board *b, char *name,
{
char
pathname
[
128
];
s
printf
(
pathname
,
"%s/%s"
,
b
->
sysbase
,
name
);
s
nprintf
(
pathname
,
sizeof
(
pathname
)
,
"%s/%s"
,
b
->
sysbase
,
name
);
return
__fdelay_sysfs_set
(
pathname
,
value
);
}
...
...
software/lib/fdelay-output.c
View file @
95ed6ec8
...
...
@@ -68,7 +68,7 @@ static int __fdelay_get_ch_fd(struct __fdelay_board *b,
if
(
b
->
fdc
[
ch14
]
<=
0
)
{
char
fname
[
128
];
s
printf
(
fname
,
"%s-%i-0-ctrl"
,
b
->
devbase
,
ch14
);
s
nprintf
(
fname
,
sizeof
(
fname
)
,
"%s-%i-0-ctrl"
,
b
->
devbase
,
ch14
);
b
->
fdc
[
ch14
]
=
open
(
fname
,
O_WRONLY
|
O_NONBLOCK
);
if
(
b
->
fdc
[
ch14
]
<
0
)
return
-
1
;
...
...
@@ -226,51 +226,51 @@ int fdelay_get_config_pulse(struct fdelay_board *userb,
memset
(
pulse
,
0
,
sizeof
(
struct
fdelay_pulse
));
s
printf
(
s
,
"fd-ch%i/%s"
,
channel
+
1
,
"mode"
);
s
nprintf
(
s
,
sizeof
(
s
),
"fd-ch%i/%s"
,
channel
+
1
,
"mode"
);
if
(
fdelay_sysfs_get
(
b
,
s
,
&
tmp
)
<
0
)
return
-
1
;
/* errno already set */
pulse
->
mode
=
tmp
;
s
printf
(
s
,
"fd-ch%i/%s"
,
channel
+
1
,
"rep"
);
s
nprintf
(
s
,
sizeof
(
s
),
"fd-ch%i/%s"
,
channel
+
1
,
"rep"
);
if
(
fdelay_sysfs_get
(
b
,
s
,
&
tmp
)
<
0
)
return
-
1
;
pulse
->
rep
=
tmp
;
s
printf
(
s
,
"fd-ch%i/%s"
,
channel
+
1
,
"start-h"
);
s
nprintf
(
s
,
sizeof
(
s
),
"fd-ch%i/%s"
,
channel
+
1
,
"start-h"
);
if
(
fdelay_sysfs_get
(
b
,
s
,
&
utc_h
)
<
0
)
return
-
1
;
s
printf
(
s
,
"fd-ch%i/%s"
,
channel
+
1
,
"start-l"
);
s
nprintf
(
s
,
sizeof
(
s
),
"fd-ch%i/%s"
,
channel
+
1
,
"start-l"
);
if
(
fdelay_sysfs_get
(
b
,
s
,
&
utc_l
)
<
0
)
return
-
1
;
pulse
->
start
.
utc
=
(((
uint64_t
)
utc_h
)
<<
32
)
|
utc_l
;
s
printf
(
s
,
"fd-ch%i/%s"
,
channel
+
1
,
"start-coarse"
);
s
nprintf
(
s
,
sizeof
(
s
),
"fd-ch%i/%s"
,
channel
+
1
,
"start-coarse"
);
if
(
fdelay_sysfs_get
(
b
,
s
,
&
pulse
->
start
.
coarse
)
<
0
)
return
-
1
;
s
printf
(
s
,
"fd-ch%i/%s"
,
channel
+
1
,
"start-fine"
);
s
nprintf
(
s
,
sizeof
(
s
),
"fd-ch%i/%s"
,
channel
+
1
,
"start-fine"
);
if
(
fdelay_sysfs_get
(
b
,
s
,
&
pulse
->
start
.
frac
)
<
0
)
return
-
1
;
s
printf
(
s
,
"fd-ch%i/%s"
,
channel
+
1
,
"end-h"
);
s
nprintf
(
s
,
sizeof
(
s
),
"fd-ch%i/%s"
,
channel
+
1
,
"end-h"
);
if
(
fdelay_sysfs_get
(
b
,
s
,
&
utc_h
)
<
0
)
return
-
1
;
s
printf
(
s
,
"fd-ch%i/%s"
,
channel
+
1
,
"end-l"
);
s
nprintf
(
s
,
sizeof
(
s
),
"fd-ch%i/%s"
,
channel
+
1
,
"end-l"
);
if
(
fdelay_sysfs_get
(
b
,
s
,
&
utc_l
)
<
0
)
return
-
1
;
pulse
->
end
.
utc
=
(((
uint64_t
)
utc_h
)
<<
32
)
|
utc_l
;
s
printf
(
s
,
"fd-ch%i/%s"
,
channel
+
1
,
"end-coarse"
);
s
nprintf
(
s
,
sizeof
(
s
),
"fd-ch%i/%s"
,
channel
+
1
,
"end-coarse"
);
if
(
fdelay_sysfs_get
(
b
,
s
,
&
pulse
->
end
.
coarse
)
<
0
)
return
-
1
;
s
printf
(
s
,
"fd-ch%i/%s"
,
channel
+
1
,
"end-fine"
);
s
nprintf
(
s
,
sizeof
(
s
),
"fd-ch%i/%s"
,
channel
+
1
,
"end-fine"
);
if
(
fdelay_sysfs_get
(
b
,
s
,
&
pulse
->
end
.
frac
)
<
0
)
return
-
1
;
s
printf
(
s
,
"fd-ch%i/%s"
,
channel
+
1
,
"delta-l"
);
s
nprintf
(
s
,
sizeof
(
s
),
"fd-ch%i/%s"
,
channel
+
1
,
"delta-l"
);
if
(
fdelay_sysfs_get
(
b
,
s
,
&
utc_l
)
<
0
)
return
-
1
;
pulse
->
loop
.
utc
=
utc_l
;
s
printf
(
s
,
"fd-ch%i/%s"
,
channel
+
1
,
"delta-coarse"
);
s
nprintf
(
s
,
sizeof
(
s
),
"fd-ch%i/%s"
,
channel
+
1
,
"delta-coarse"
);
if
(
fdelay_sysfs_get
(
b
,
s
,
&
pulse
->
loop
.
coarse
)
<
0
)
return
-
1
;
s
printf
(
s
,
"fd-ch%i/%s"
,
channel
+
1
,
"delta-fine"
);
s
nprintf
(
s
,
sizeof
(
s
),
"fd-ch%i/%s"
,
channel
+
1
,
"delta-fine"
);
if
(
fdelay_sysfs_get
(
b
,
s
,
&
pulse
->
loop
.
frac
)
<
0
)
return
-
1
;
...
...
@@ -278,15 +278,15 @@ int fdelay_get_config_pulse(struct fdelay_board *userb,
* Now, to return consistent values to the user, we must
* un-apply all offsets that the driver added
*/
s
printf
(
s
,
"fd-ch%i/%s"
,
channel
+
1
,
"delay-offset"
);
s
nprintf
(
s
,
sizeof
(
s
),
"fd-ch%i/%s"
,
channel
+
1
,
"delay-offset"
);
if
(
fdelay_sysfs_get
(
b
,
s
,
&
output_offset
)
<
0
)
return
-
1
;
s
printf
(
s
,
"fd-ch%i/%s"
,
channel
+
1
,
"user-offset"
);
s
nprintf
(
s
,
sizeof
(
s
),
"fd-ch%i/%s"
,
channel
+
1
,
"user-offset"
);
if
(
fdelay_sysfs_get
(
b
,
s
,
&
output_user_offset
)
<
0
)
return
-
1
;
s
printf
(
s
,
"fd-input/%s"
,
"offset"
);
s
nprintf
(
s
,
sizeof
(
s
),
"fd-input/%s"
,
"offset"
);
if
(
fdelay_sysfs_get
(
b
,
s
,
&
input_offset
)
<
0
)
return
-
1
;
...
...
@@ -365,7 +365,7 @@ int fdelay_has_triggered(struct fdelay_board *userb, int channel)
char
s
[
32
];
uint32_t
mode
;
s
printf
(
s
,
"fd-ch%i/mode"
,
channel
+
1
);
s
nprintf
(
s
,
sizeof
(
s
),
"fd-ch%i/mode"
,
channel
+
1
);
if
(
fdelay_sysfs_get
(
b
,
s
,
&
mode
)
<
0
)
return
-
1
;
/* errno already set */
return
(
mode
&
0x80
)
!=
0
;
...
...
software/lib/fdelay-tdc.c
View file @
95ed6ec8
...
...
@@ -70,7 +70,7 @@ static int __fdelay_open_tdc(struct __fdelay_board *b)
if
(
b
->
fdc
[
0
]
<=
0
)
{
char
fname
[
128
];
s
printf
(
fname
,
"%s-0-0-ctrl"
,
b
->
devbase
);
s
nprintf
(
fname
,
sizeof
(
fname
)
,
"%s-0-0-ctrl"
,
b
->
devbase
);
b
->
fdc
[
0
]
=
open
(
fname
,
O_RDONLY
|
O_NONBLOCK
);
}
return
b
->
fdc
[
0
];
...
...
software/tools/fmc-fdelay-calibration.c
View file @
95ed6ec8
...
...
@@ -135,7 +135,7 @@ static int fmc_fdelay_calibration_write(unsigned int devid, struct fd_calibratio
int
fd
;
int
ret
;
s
printf
(
path
,
s
nprintf
(
path
,
sizeof
(
path
)
,
"/sys/bus/zio/devices/fd-%04x/calibration_data"
,
devid
);
...
...
software/tools/fmc-fdelay-pulse.c
View file @
95ed6ec8
...
...
@@ -8,6 +8,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <inttypes.h>
#include <time.h>
#include "fdelay-lib.h"
...
...
@@ -398,7 +399,12 @@ int main(int argc, char **argv)
exit
(
1
);
}
while
(
trigger_wait
)
{
usleep
(
10
*
1000
);
struct
timespec
ts
=
{
.
tv_sec
=
0
,
.
tv_nsec
=
10
*
1000
,
};
nanosleep
(
&
ts
,
NULL
);
i
=
fdelay_has_triggered
(
b
,
channel
);
if
(
i
<
0
)
{
fprintf
(
stderr
,
"%s: waiting for trigger: %s
\n
"
,
...
...
software/tools/tools-util.c
View file @
95ed6ec8
...
...
@@ -158,13 +158,13 @@ void report_output_config_raw(int channel, struct fdelay_pulse *p, int umode)
char
mode
[
80
];
int
m
=
p
->
mode
&
0x7f
;
if
(
m
==
FD_OUT_MODE_DISABLED
)
str
cpy
(
mode
,
"disabled"
);
else
if
(
m
==
FD_OUT_MODE_PULSE
)
str
cpy
(
mode
,
"pulse"
);
else
if
(
m
==
FD_OUT_MODE_DELAY
)
str
cpy
(
mode
,
"delay"
);
else
s
printf
(
mode
,
"%i (0x%04x)"
,
p
->
mode
,
p
->
mode
);
if
(
m
==
FD_OUT_MODE_DISABLED
)
str
ncpy
(
mode
,
"disabled"
,
sizeof
(
mode
)
);
else
if
(
m
==
FD_OUT_MODE_PULSE
)
str
ncpy
(
mode
,
"pulse"
,
sizeof
(
mode
)
);
else
if
(
m
==
FD_OUT_MODE_DELAY
)
str
ncpy
(
mode
,
"delay"
,
sizeof
(
mode
)
);
else
s
nprintf
(
mode
,
sizeof
(
mode
)
,
"%i (0x%04x)"
,
p
->
mode
,
p
->
mode
);
if
(
p
->
mode
&
0x80
)
str
cat
(
mode
,
" (triggered)"
);
str
ncat
(
mode
,
" (triggered)"
,
sizeof
(
mode
)
-
strlen
(
mode
)
);
printf
(
"Channel %i, mode %s, repeat %i %s
\n
"
,
FDELAY_OUTPUT_HW_TO_USER
(
channel
),
mode
,
p
->
rep
,
p
->
rep
==
-
1
?
"(infinite)"
:
""
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment