diff options
author | NIIBE Yutaka <[email protected]> | 2023-07-17 06:23:54 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2023-07-17 06:23:54 +0000 |
commit | 0e8105a364c8cac68a254b5617a83987cc44fcff (patch) | |
tree | 05417cd886a1ac1957970449a3396b4d439bc8d7 | |
parent | yat2m: Fix Windows build (diff) | |
download | libgpg-error-0e8105a364c8cac68a254b5617a83987cc44fcff.tar.gz libgpg-error-0e8105a364c8cac68a254b5617a83987cc44fcff.zip |
gpgscm: Incorporate changes from GnuPG.
* gpgscm/scheme.c [__GNUC__] (type_to_string): Use
__builtin_unreachable for GCC.
* gpgscm/ffi.c (do_get_temp_path): Remove the last backslash.
* gpgscm/ffi.c (do_chdir): Use gpg_error_from_syserror.
--
Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r-- | gpgscm/ffi.c | 7 | ||||
-rw-r--r-- | gpgscm/scheme.c | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/gpgscm/ffi.c b/gpgscm/ffi.c index 2067b0d..77a81b8 100644 --- a/gpgscm/ffi.c +++ b/gpgscm/ffi.c @@ -212,7 +212,7 @@ do_chdir (scheme *sc, pointer args) FFI_ARG_OR_RETURN (sc, char *, name, path, args); FFI_ARGS_DONE_OR_RETURN (sc, args); if (chdir (name)) - FFI_RETURN_ERR (sc, errno); + FFI_RETURN_ERR (sc, gpg_error_from_syserror ()); FFI_RETURN (sc); } @@ -351,6 +351,11 @@ do_get_temp_path (scheme *sc, pointer args) #ifdef HAVE_W32_SYSTEM if (GetTempPath (MAX_PATH+1, buffer) == 0) FFI_RETURN_STRING (sc, "/temp"); + else + { + size_t len = strlen (buffer); + buffer[len-1] = 0; + } FFI_RETURN_STRING (sc, buffer); #else FFI_RETURN_STRING (sc, "/tmp"); diff --git a/gpgscm/scheme.c b/gpgscm/scheme.c index eb57ba4..b53f79e 100644 --- a/gpgscm/scheme.c +++ b/gpgscm/scheme.c @@ -170,7 +170,11 @@ type_to_string (enum scheme_types typ) case T_SINK: return "sink"; case T_FRAME: return "frame"; } +#ifdef __GNUC__ + __builtin_unreachable (); +#else assert (! "not reached"); +#endif } /* ADJ is enough slack to align cells in a TYPE_BITS-bit boundary */ @@ -5570,7 +5574,7 @@ static const struct scheme_interface vtbl = { }; #endif -scheme *scheme_init_new() { +scheme *scheme_init_new(void) { scheme *sc=(scheme*)malloc(sizeof(scheme)); if(!scheme_init(sc)) { free(sc); |