diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-25 23:14:45 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-25 23:14:45 +0000 |
commit | c3fee331d5dd4784c7a793f5a63853101e1ceee3 (patch) | |
tree | f859e6ac09758925222785ab09a1965b0db66e11 /src/util/disk.c | |
parent | 200c39244ad165f003ec810320b415dda6ec7542 (diff) | |
download | gnunet-c3fee331d5dd4784c7a793f5a63853101e1ceee3.tar.gz gnunet-c3fee331d5dd4784c7a793f5a63853101e1ceee3.zip |
-make sure we get the correct errno back after GNUNET_NETWORK_socket_create()
Diffstat (limited to 'src/util/disk.c')
-rw-r--r-- | src/util/disk.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/util/disk.c b/src/util/disk.c index c5a1b82c7..063ffc946 100644 --- a/src/util/disk.c +++ b/src/util/disk.c | |||
@@ -939,7 +939,9 @@ GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle *h, | |||
939 | return GNUNET_SYSERR; | 939 | return GNUNET_SYSERR; |
940 | } | 940 | } |
941 | } | 941 | } |
942 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Read %u bytes\n", bytes_read); | 942 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
943 | "Read %u bytes\n", | ||
944 | bytes_read); | ||
943 | } | 945 | } |
944 | else | 946 | else |
945 | { | 947 | { |
@@ -982,8 +984,10 @@ GNUNET_DISK_fn_read (const char *fn, | |||
982 | struct GNUNET_DISK_FileHandle *fh; | 984 | struct GNUNET_DISK_FileHandle *fh; |
983 | ssize_t ret; | 985 | ssize_t ret; |
984 | 986 | ||
985 | fh = GNUNET_DISK_file_open (fn, GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE); | 987 | fh = GNUNET_DISK_file_open (fn, |
986 | if (!fh) | 988 | GNUNET_DISK_OPEN_READ, |
989 | GNUNET_DISK_PERM_NONE); | ||
990 | if (NULL == fh) | ||
987 | return GNUNET_SYSERR; | 991 | return GNUNET_SYSERR; |
988 | ret = GNUNET_DISK_file_read (fh, result, len); | 992 | ret = GNUNET_DISK_file_read (fh, result, len); |
989 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh)); | 993 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh)); |
@@ -1196,7 +1200,7 @@ GNUNET_DISK_directory_scan (const char *dir_name, | |||
1196 | unsigned int name_len; | 1200 | unsigned int name_len; |
1197 | unsigned int n_size; | 1201 | unsigned int n_size; |
1198 | 1202 | ||
1199 | GNUNET_assert (dir_name != NULL); | 1203 | GNUNET_assert (NULL != dir_name); |
1200 | dname = GNUNET_STRINGS_filename_expand (dir_name); | 1204 | dname = GNUNET_STRINGS_filename_expand (dir_name); |
1201 | if (dname == NULL) | 1205 | if (dname == NULL) |
1202 | return GNUNET_SYSERR; | 1206 | return GNUNET_SYSERR; |
@@ -1208,7 +1212,7 @@ GNUNET_DISK_directory_scan (const char *dir_name, | |||
1208 | GNUNET_free (dname); | 1212 | GNUNET_free (dname); |
1209 | return GNUNET_SYSERR; | 1213 | return GNUNET_SYSERR; |
1210 | } | 1214 | } |
1211 | if (!S_ISDIR (istat.st_mode)) | 1215 | if (! S_ISDIR (istat.st_mode)) |
1212 | { | 1216 | { |
1213 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1217 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1214 | _("Expected `%s' to be a directory!\n"), | 1218 | _("Expected `%s' to be a directory!\n"), |
@@ -1218,7 +1222,7 @@ GNUNET_DISK_directory_scan (const char *dir_name, | |||
1218 | } | 1222 | } |
1219 | errno = 0; | 1223 | errno = 0; |
1220 | dinfo = OPENDIR (dname); | 1224 | dinfo = OPENDIR (dname); |
1221 | if ((errno == EACCES) || (dinfo == NULL)) | 1225 | if ((errno == EACCES) || (NULL == dinfo)) |
1222 | { | 1226 | { |
1223 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "opendir", dname); | 1227 | LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "opendir", dname); |
1224 | if (dinfo != NULL) | 1228 | if (dinfo != NULL) |
@@ -1229,12 +1233,12 @@ GNUNET_DISK_directory_scan (const char *dir_name, | |||
1229 | name_len = 256; | 1233 | name_len = 256; |
1230 | n_size = strlen (dname) + name_len + 2; | 1234 | n_size = strlen (dname) + name_len + 2; |
1231 | name = GNUNET_malloc (n_size); | 1235 | name = GNUNET_malloc (n_size); |
1232 | while ((finfo = READDIR (dinfo)) != NULL) | 1236 | while (NULL != (finfo = READDIR (dinfo))) |
1233 | { | 1237 | { |
1234 | if ((0 == strcmp (finfo->d_name, ".")) || | 1238 | if ((0 == strcmp (finfo->d_name, ".")) || |
1235 | (0 == strcmp (finfo->d_name, ".."))) | 1239 | (0 == strcmp (finfo->d_name, ".."))) |
1236 | continue; | 1240 | continue; |
1237 | if (callback != NULL) | 1241 | if (NULL != callback) |
1238 | { | 1242 | { |
1239 | if (name_len < strlen (finfo->d_name)) | 1243 | if (name_len < strlen (finfo->d_name)) |
1240 | { | 1244 | { |