Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC TDC 1ns 5cha
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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 TDC 1ns 5cha
Commits
4ea774ad
Commit
4ea774ad
authored
Oct 25, 2018
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*: reduce variable scope
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
d7f81c3e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
11 deletions
+12
-11
fmctdc-lib.c
lib/fmctdc-lib.c
+10
-9
fmc-tdc-offset.c
tools/fmc-tdc-offset.c
+2
-2
No files found.
lib/fmctdc-lib.c
View file @
4ea774ad
...
@@ -727,7 +727,6 @@ int fmctdc_read(struct fmctdc_board *userb, unsigned int channel,
...
@@ -727,7 +727,6 @@ int fmctdc_read(struct fmctdc_board *userb, unsigned int channel,
{
{
__define_board
(
b
,
userb
);
__define_board
(
b
,
userb
);
int
i
;
int
i
;
int
n_ts
;
fd_set
set
;
fd_set
set
;
if
(
channel
>=
FMCTDC_NUM_CHANNELS
)
{
if
(
channel
>=
FMCTDC_NUM_CHANNELS
)
{
...
@@ -737,7 +736,8 @@ int fmctdc_read(struct fmctdc_board *userb, unsigned int channel,
...
@@ -737,7 +736,8 @@ int fmctdc_read(struct fmctdc_board *userb, unsigned int channel,
i
=
0
;
i
=
0
;
while
(
i
<
n
)
{
while
(
i
<
n
)
{
n_ts
=
__fmctdc_read
(
userb
,
channel
,
&
t
[
i
],
1
);
int
n_ts
=
__fmctdc_read
(
userb
,
channel
,
&
t
[
i
],
1
);
if
(
n_ts
<
0
&&
errno
!=
EAGAIN
)
{
if
(
n_ts
<
0
&&
errno
!=
EAGAIN
)
{
if
(
i
==
0
)
if
(
i
==
0
)
return
-
1
;
return
-
1
;
...
@@ -781,10 +781,10 @@ int fmctdc_read(struct fmctdc_board *userb, unsigned int channel,
...
@@ -781,10 +781,10 @@ int fmctdc_read(struct fmctdc_board *userb, unsigned int channel,
int
fmctdc_fread
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
,
int
fmctdc_fread
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
,
struct
fmctdc_time
*
t
,
int
n
)
struct
fmctdc_time
*
t
,
int
n
)
{
{
int
i
,
loop
;
int
i
;
for
(
i
=
0
;
i
<
n
;)
{
for
(
i
=
0
;
i
<
n
;)
{
loop
=
fmctdc_read
(
userb
,
channel
,
t
+
i
,
n
-
i
,
0
);
int
loop
=
fmctdc_read
(
userb
,
channel
,
t
+
i
,
n
-
i
,
0
);
if
(
loop
<
0
)
if
(
loop
<
0
)
return
-
1
;
return
-
1
;
i
+=
loop
;
i
+=
loop
;
...
@@ -805,13 +805,13 @@ int fmctdc_set_time(struct fmctdc_board *userb, struct fmctdc_time *t)
...
@@ -805,13 +805,13 @@ int fmctdc_set_time(struct fmctdc_board *userb, struct fmctdc_time *t)
{
{
__define_board
(
b
,
userb
);
__define_board
(
b
,
userb
);
uint32_t
attrs
[
ARRAY_SIZE
(
names
)];
uint32_t
attrs
[
ARRAY_SIZE
(
names
)];
int
i
,
ret
;
int
i
;
attrs
[
0
]
=
t
->
seconds
&
0xffffffff
;
attrs
[
0
]
=
t
->
seconds
&
0xffffffff
;
attrs
[
1
]
=
t
->
coarse
;
attrs
[
1
]
=
t
->
coarse
;
for
(
i
=
ARRAY_SIZE
(
names
)
-
1
;
i
>=
0
;
i
--
)
{
for
(
i
=
ARRAY_SIZE
(
names
)
-
1
;
i
>=
0
;
i
--
)
{
ret
=
fmctdc_sysfs_set
(
b
,
names
[
i
],
attrs
+
i
);
int
ret
=
fmctdc_sysfs_set
(
b
,
names
[
i
],
attrs
+
i
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
}
}
...
@@ -830,10 +830,10 @@ int fmctdc_get_time(struct fmctdc_board *userb, struct fmctdc_time *t)
...
@@ -830,10 +830,10 @@ int fmctdc_get_time(struct fmctdc_board *userb, struct fmctdc_time *t)
{
{
__define_board
(
b
,
userb
);
__define_board
(
b
,
userb
);
uint32_t
attrs
[
ARRAY_SIZE
(
names
)];
uint32_t
attrs
[
ARRAY_SIZE
(
names
)];
int
i
,
ret
;
int
i
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
names
);
i
++
)
{
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
names
);
i
++
)
{
ret
=
fmctdc_sysfs_get
(
b
,
names
[
i
],
attrs
+
i
);
int
ret
=
fmctdc_sysfs_get
(
b
,
names
[
i
],
attrs
+
i
);
if
(
ret
<
0
)
if
(
ret
<
0
)
return
ret
;
return
ret
;
}
}
...
@@ -974,7 +974,6 @@ int fmctdc_reference_get(struct fmctdc_board *userb, unsigned int ch_target)
...
@@ -974,7 +974,6 @@ int fmctdc_reference_get(struct fmctdc_board *userb, unsigned int ch_target)
int
fmctdc_flush
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
)
int
fmctdc_flush
(
struct
fmctdc_board
*
userb
,
unsigned
int
channel
)
{
{
struct
__fmctdc_board
*
b
=
(
void
*
)(
userb
);
struct
__fmctdc_board
*
b
=
(
void
*
)(
userb
);
char
path
[
64
];
int
en
,
err
;
int
en
,
err
;
uint32_t
val
=
1
;
uint32_t
val
=
1
;
...
@@ -1003,6 +1002,8 @@ int fmctdc_flush(struct fmctdc_board *userb, unsigned int channel)
...
@@ -1003,6 +1002,8 @@ int fmctdc_flush(struct fmctdc_board *userb, unsigned int channel)
n
=
fmctdc_read
(
userb
,
channel
,
ts
,
100
,
O_NONBLOCK
);
n
=
fmctdc_read
(
userb
,
channel
,
ts
,
100
,
O_NONBLOCK
);
}
while
(
n
>
0
);
}
while
(
n
>
0
);
}
else
{
}
else
{
char
path
[
64
];
/* Flush ZIO buffer */
/* Flush ZIO buffer */
snprintf
(
path
,
sizeof
(
path
),
snprintf
(
path
,
sizeof
(
path
),
"ft-ch%u/chan0/buffer/flush"
,
"ft-ch%u/chan0/buffer/flush"
,
...
...
tools/fmc-tdc-offset.c
View file @
4ea774ad
...
@@ -12,7 +12,7 @@ char git_version[] = "git version: " GIT_VERSION;
...
@@ -12,7 +12,7 @@ char git_version[] = "git version: " GIT_VERSION;
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
int32_t
offset
;
int32_t
offset
;
int
err
,
ret
,
i
,
channel
,
ch_start
=
FMCTDC_CH_1
,
ch_end
=
FMCTDC_CH_LAST
;
int
err
,
i
,
channel
,
ch_start
=
FMCTDC_CH_1
,
ch_end
=
FMCTDC_CH_LAST
;
init
(
argc
,
argv
);
init
(
argc
,
argv
);
...
@@ -34,7 +34,7 @@ int main(int argc, char **argv)
...
@@ -34,7 +34,7 @@ int main(int argc, char **argv)
}
}
if
(
argc
>=
4
)
{
if
(
argc
>=
4
)
{
ret
=
sscanf
(
argv
[
3
],
"%"
SCNi32
,
&
offset
);
int
ret
=
sscanf
(
argv
[
3
],
"%"
SCNi32
,
&
offset
);
if
(
ret
!=
1
)
{
if
(
ret
!=
1
)
{
fprintf
(
stderr
,
"%s: invalid command.
\n
"
,
argv
[
0
]);
fprintf
(
stderr
,
"%s: invalid command.
\n
"
,
argv
[
0
]);
return
-
1
;
return
-
1
;
...
...
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