* [Patch] associate a deallocation for opendir
@ 2022-03-11 20:29 Steve Grubb
2022-03-11 21:41 ` Paul Eggert
2022-03-14 8:09 ` Siddhesh Poyarekar
0 siblings, 2 replies; 3+ messages in thread
From: Steve Grubb @ 2022-03-11 20:29 UTC (permalink / raw)
To: libc-alpha
This patch associates closedir as a deallocation for opendir and fdopendir.
This required moving the closedir declaration above the other 2 functions.
---
dirent.h | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
---
diff -urp glibc-2.35.9000-111-g2bbc694df2.orig/dirent/dirent.h glibc-2.35.9000-111-g2bbc694df2/dirent/dirent.h
--- glibc-2.35.9000-111-g2bbc694df2.orig/dirent/dirent.h 2022-02-28 10:47:38.000000000 -0500
+++ glibc-2.35.9000-111-g2bbc694df2/dirent/dirent.h 2022-03-11 14:37:57.828733684 -0500
@@ -126,28 +126,30 @@ enum
The actual structure is opaque to users. */
typedef struct __dirstream DIR;
+/* Close the directory stream DIRP.
+ Return 0 if successful, -1 if not.
+
+ This function is a possible cancellation point and therefore not
+ marked with __THROW. */
+extern int closedir (DIR *__dirp) __nonnull ((1));
+
/* Open a directory stream on NAME.
Return a DIR stream on the directory, or NULL if it could not be opened.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern DIR *opendir (const char *__name) __nonnull ((1));
+extern DIR *opendir (const char *__name) __nonnull ((1))
+ __attribute_malloc__ __attr_dealloc (closedir, 1);
#ifdef __USE_XOPEN2K8
/* Same as opendir, but open the stream on the file descriptor FD.
This function is a possible cancellation point and therefore not
marked with __THROW. */
-extern DIR *fdopendir (int __fd);
+extern DIR *fdopendir (int __fd)
+ __attribute_malloc__ __attr_dealloc (closedir, 1);
#endif
-/* Close the directory stream DIRP.
- Return 0 if successful, -1 if not.
-
- This function is a possible cancellation point and therefore not
- marked with __THROW. */
-extern int closedir (DIR *__dirp) __nonnull ((1));
-
/* Read a directory entry from DIRP. Return a pointer to a `struct
dirent' describing the entry, or NULL for EOF or error. The
storage returned may be overwritten by a later readdir call on the
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch] associate a deallocation for opendir
2022-03-11 20:29 [Patch] associate a deallocation for opendir Steve Grubb
@ 2022-03-11 21:41 ` Paul Eggert
2022-03-14 8:09 ` Siddhesh Poyarekar
1 sibling, 0 replies; 3+ messages in thread
From: Paul Eggert @ 2022-03-11 21:41 UTC (permalink / raw)
To: Steve Grubb; +Cc: libc-alpha
Thanks, this patch looks good.
FWIW Gnulib/lib/dirent.in.h has been doing something similar since
August and we haven't run into problems.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch] associate a deallocation for opendir
2022-03-11 20:29 [Patch] associate a deallocation for opendir Steve Grubb
2022-03-11 21:41 ` Paul Eggert
@ 2022-03-14 8:09 ` Siddhesh Poyarekar
1 sibling, 0 replies; 3+ messages in thread
From: Siddhesh Poyarekar @ 2022-03-14 8:09 UTC (permalink / raw)
To: Steve Grubb, libc-alpha
LGTM too. I'll push once I finish testing it.
Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
On 12/03/2022 01:59, Steve Grubb via Libc-alpha wrote:
> This patch associates closedir as a deallocation for opendir and fdopendir.
> This required moving the closedir declaration above the other 2 functions.
>
> ---
> dirent.h | 20 +++++++++++---------
> 1 file changed, 11 insertions(+), 9 deletions(-)
> ---
> diff -urp glibc-2.35.9000-111-g2bbc694df2.orig/dirent/dirent.h glibc-2.35.9000-111-g2bbc694df2/dirent/dirent.h
> --- glibc-2.35.9000-111-g2bbc694df2.orig/dirent/dirent.h 2022-02-28 10:47:38.000000000 -0500
> +++ glibc-2.35.9000-111-g2bbc694df2/dirent/dirent.h 2022-03-11 14:37:57.828733684 -0500
> @@ -126,28 +126,30 @@ enum
> The actual structure is opaque to users. */
> typedef struct __dirstream DIR;
>
> +/* Close the directory stream DIRP.
> + Return 0 if successful, -1 if not.
> +
> + This function is a possible cancellation point and therefore not
> + marked with __THROW. */
> +extern int closedir (DIR *__dirp) __nonnull ((1));
> +
> /* Open a directory stream on NAME.
> Return a DIR stream on the directory, or NULL if it could not be opened.
>
> This function is a possible cancellation point and therefore not
> marked with __THROW. */
> -extern DIR *opendir (const char *__name) __nonnull ((1));
> +extern DIR *opendir (const char *__name) __nonnull ((1))
> + __attribute_malloc__ __attr_dealloc (closedir, 1);
>
> #ifdef __USE_XOPEN2K8
> /* Same as opendir, but open the stream on the file descriptor FD.
>
> This function is a possible cancellation point and therefore not
> marked with __THROW. */
> -extern DIR *fdopendir (int __fd);
> +extern DIR *fdopendir (int __fd)
> + __attribute_malloc__ __attr_dealloc (closedir, 1);
> #endif
>
> -/* Close the directory stream DIRP.
> - Return 0 if successful, -1 if not.
> -
> - This function is a possible cancellation point and therefore not
> - marked with __THROW. */
> -extern int closedir (DIR *__dirp) __nonnull ((1));
> -
> /* Read a directory entry from DIRP. Return a pointer to a `struct
> dirent' describing the entry, or NULL for EOF or error. The
> storage returned may be overwritten by a later readdir call on the
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-14 8:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-11 20:29 [Patch] associate a deallocation for opendir Steve Grubb
2022-03-11 21:41 ` Paul Eggert
2022-03-14 8:09 ` Siddhesh Poyarekar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).