Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
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
dCache
cta
Commits
3ea343d9
Commit
3ea343d9
authored
11 years ago
by
Steven Murray
Committed by
Steven Murray
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
sstrerror_r prototype now matches that of the XSI strerror_r
parent
6129011a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mediachanger/castorrmc/common/serror.cpp
+29
-8
29 additions, 8 deletions
mediachanger/castorrmc/common/serror.cpp
mediachanger/castorrmc/h/serrno.h
+29
-2
29 additions, 2 deletions
mediachanger/castorrmc/h/serrno.h
with
58 additions
and
10 deletions
mediachanger/castorrmc/common/serror.cpp
+
29
−
8
View file @
3ea343d9
...
...
@@ -491,10 +491,16 @@ char *sys_secerrlist[ESECMAXERR-ESECBASEOFF+2] =
*------------------------------------------------------------------------
*/
char
*
sstrerror_r
(
const
int
n
,
char
*
const
buf
,
const
size_t
buflen
)
{
int
sstrerror_r
(
const
int
n
,
char
*
const
buf
,
const
size_t
buflen
)
{
char
*
tmpstr
;
char
strerror_r_buf
[
100
];
if
(
buf
==
NULL
||
buflen
<=
0
)
return
(
NULL
);
if
(
buf
==
NULL
||
buflen
<=
0
)
{
errno
=
EINVAL
;
serrno
=
EINVAL
;
return
-
1
;
}
memset
(
buf
,
'\0'
,
buflen
);
tmpstr
=
NULL
;
...
...
@@ -608,14 +614,20 @@ char * sstrerror_r(const int n, char *const buf, const size_t buflen) {
*/
sprintf
(
buf
,
"%*s: %10d"
,
(
int
)
buflen
-
14
,
sys_serrlist
[
SEMAXERR
+
1
-
SEBASEOFF
],
n
);
}
return
(
buf
)
;
return
0
;
}
void
sperror
(
char
*
msg
)
{
char
buf
[
80
];
if
(
serrno
)
{
fprintf
(
stderr
,
"%s: %s
\n
"
,
msg
,
sstrerror_r
(
serrno
,
buf
,
80
));
if
(
sstrerror_r
(
serrno
,
buf
,
sizeof
(
buf
)))
{
/* sstrerror_r() failed so just print msg */
fprintf
(
stderr
,
"%s
\n
"
,
msg
);
}
else
{
/* sstrerror_r() succeeded so print both msg and buf */
fprintf
(
stderr
,
"%s: %s
\n
"
,
msg
,
buf
);
}
}
else
{
perror
(
msg
);
}
...
...
@@ -623,11 +635,20 @@ void sperror(char *msg)
static
int
sstrerror_key
=
-
1
;
char
*
sstrerror
(
int
n
)
{
char
*
sstrerror
(
const
int
n
)
{
void
*
buf
=
NULL
;
int
buflen
=
80
;
Cglobals_get
(
&
sstrerror_key
,
&
buf
,
buflen
);
return
(
sstrerror_r
(
n
,(
char
*
)
buf
,
buflen
));
if
(
Cglobals_get
(
&
sstrerror_key
,
&
buf
,
buflen
))
{
return
"Unknown error"
": No thread specific memory to determine error string"
": Cglobals_get() failed"
;
}
if
(
sstrerror_r
(
n
,(
char
*
)
buf
,
buflen
))
{
return
"Unknown error"
": sstrerror_r() failed"
;
}
else
{
return
(
char
*
)
buf
;
}
}
This diff is collapsed.
Click to expand it.
mediachanger/castorrmc/h/serrno.h
+
29
−
2
View file @
3ea343d9
...
...
@@ -485,8 +485,35 @@ EXTERN_C int *C__serrno (void);
*/
#define serrno (*C__serrno())
EXTERN_C
char
*
sstrerror_r
(
const
int
n
,
char
*
const
buf
,
const
size_t
buflen
);
EXTERN_C
char
*
sstrerror
(
int
);
/**
* Writes the string representation of the specified error code into the
* specified buffer.
*
* The string representation is truncated if the specified buffer is too small.
* In case of such a truncation the string written to the specified buffer is
* null terminated.
*
* @param n The numeric error code.
* @param buf The buffer to which the string representation should be written.
* @param buflen The length of the buffer.
* @return 0 on success or -1 on failure. In the case of a failure both errno
* and serrno are set to indicate the type of error.
*/
EXTERN_C
int
sstrerror_r
(
const
int
n
,
char
*
const
buf
,
const
size_t
buflen
);
/**
* Returns the string representation of the specified error code.
*
* Allocates some thread specfic memory if needed using Cglobals_get() and then
* passes that memory to sstrerror_r along with the specified error code.
*
* A string is always returned. This function never returns NULL.
*
* @param n The numeric error code.
* @return The string representation.
*/
EXTERN_C
char
*
sstrerror
(
const
int
n
);
EXTERN_C
void
sperror
(
char
*
);
extern
char
*
sys_serrlist
[];
/* Error text array */
...
...
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