X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Futils_tools.c;h=23e4acb42c3e0947a7496cb8801ece1b2fef78fa;hb=965f0e55d4136f7f78aa1bd05695302c980765d2;hp=84329c683af3d366d2adfe6ad49dd7bab6c483cb;hpb=83f02e66827fa6fa66f9b73a009d2ba51d22352d;p=platform%2Fupstream%2Fcryptsetup.git diff --git a/src/utils_tools.c b/src/utils_tools.c index 84329c6..23e4acb 100644 --- a/src/utils_tools.c +++ b/src/utils_tools.c @@ -1,14 +1,15 @@ /* * cryptsetup - setup cryptographic volumes for dm-crypt * - * Copyright (C) 2004, Christophe Saout + * Copyright (C) 2004, Jana Saout * Copyright (C) 2004-2007, Clemens Fruhwirth * Copyright (C) 2009-2012, Red Hat, Inc. All rights reserved. - * Copyright (C) 2009-2012, Milan Broz + * Copyright (C) 2009-2014, Milan Broz * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -142,6 +143,7 @@ int yesDialog(const char *msg, void *usrptr __attribute__((unused))) if(isatty(STDIN_FILENO) && !opt_batch_mode) { log_std("\nWARNING!\n========\n"); log_std("%s\n\nAre you sure? (Type uppercase yes): ", msg); + fflush(stdout); if(getline(&answer, &size, stdin) == -1) { r = 0; /* Aborted by signal */ @@ -162,7 +164,7 @@ int yesDialog(const char *msg, void *usrptr __attribute__((unused))) void show_status(int errcode) { - char error[256], *error_; + char error[256]; if(!opt_verbose) return; @@ -174,12 +176,16 @@ void show_status(int errcode) crypt_get_error(error, sizeof(error)); - if (!error[0]) { - error_ = strerror_r(-errcode, error, sizeof(error)); - if (error_ != error) { + if (*error) { +#ifdef STRERROR_R_CHAR_P /* GNU-specific strerror_r */ + char *error_ = strerror_r(-errcode, error, sizeof(error)); + if (error_ != error) strncpy(error, error_, sizeof(error)); - error[sizeof(error) - 1] = '\0'; - } +#else /* POSIX strerror_r variant */ + if (strerror_r(-errcode, error, sizeof(error))) + *error = '\0'; +#endif + error[sizeof(error) - 1] = '\0'; } log_err(_("Command failed with code %i"), -errcode);