Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
4e84bd2c
Commit
4e84bd2c
authored
Aug 23, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
linsys_sdi: simplify and fix sysfs usage
parent
0aa6c19c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
30 deletions
+19
-30
modules/access/linsys/linsys_sdi.c
modules/access/linsys/linsys_sdi.c
+19
-30
No files found.
modules/access/linsys/linsys_sdi.c
View file @
4e84bd2c
...
...
@@ -33,6 +33,7 @@
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
...
...
@@ -1660,47 +1661,35 @@ static int HandleSDBuffer( demux_t *p_demux, uint8_t *p_buffer,
static
int
ReadULSysfs
(
const
char
*
psz_fmt
,
unsigned
int
i_link
)
{
char
psz_file
[
MAXLEN
],
psz_data
[
MAXLEN
];
char
*
psz_tmp
;
int
i_fd
;
ssize_t
i_ret
;
char
psz_file
[
MAXLEN
];
unsigned
int
i_data
;
snprintf
(
psz_file
,
sizeof
(
psz_file
)
-
1
,
psz_fmt
,
i_link
);
snprintf
(
psz_file
,
sizeof
(
psz_file
),
psz_fmt
,
i_link
);
if
(
(
i_fd
=
vlc_open
(
psz_file
,
O_RDONLY
))
<
0
)
return
i_fd
;
i_ret
=
read
(
i_fd
,
psz_data
,
sizeof
(
psz_data
)
);
close
(
i_fd
);
if
(
i_ret
<
0
)
return
i_ret
;
i_data
=
strtoul
(
psz_data
,
&
psz_tmp
,
0
);
if
(
*
psz_tmp
!=
'\n'
)
FILE
*
stream
=
vlc_fopen
(
psz_file
,
"rt"
);
if
(
stream
==
NULL
)
return
-
1
;
return
i_data
;
int
ret
=
fscanf
(
stream
,
"%u"
,
&
i_data
);
fclose
(
stream
);
return
(
ret
==
1
&&
i_data
<=
INT_MAX
)
?
(
int
)
i_data
:
-
1
;
}
static
ssize_
t
WriteULSysfs
(
const
char
*
psz_fmt
,
unsigned
int
i_link
,
unsigned
int
i_buf
)
static
in
t
WriteULSysfs
(
const
char
*
psz_fmt
,
unsigned
int
i_link
,
unsigned
int
i_buf
)
{
char
psz_file
[
MAXLEN
],
psz_data
[
MAXLEN
];
int
i_fd
;
ssize_t
i_ret
;
snprintf
(
psz_file
,
sizeof
(
psz_file
)
-
1
,
psz_fmt
,
i_link
);
char
psz_file
[
MAXLEN
];
snprintf
(
psz_
data
,
sizeof
(
psz_data
)
-
1
,
"%u
\n
"
,
i_buf
);
snprintf
(
psz_
file
,
sizeof
(
psz_file
),
psz_fmt
,
i_link
);
if
(
(
i_fd
=
vlc_open
(
psz_file
,
O_WRONLY
))
<
0
)
return
i_fd
;
FILE
*
stream
=
vlc_fopen
(
psz_file
,
"wt"
);
if
(
stream
==
NULL
)
return
-
1
;
i
_ret
=
write
(
i_fd
,
psz_data
,
strlen
(
psz_data
)
+
1
);
close
(
i_fd
);
return
i_
ret
;
i
nt
ret
=
fprintf
(
stream
,
"%u
\n
"
,
i_buf
);
fclose
(
stream
);
return
ret
;
}
static
int
InitCapture
(
demux_t
*
p_demux
)
...
...
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