nis: Fix leak on realloc failure in nis_getnames [BZ #28150]
[glibc.git] / stdio-common / Makefile
blob803f16dae030cb7241232c29c11408e57b0526b3
1 # Copyright (C) 1991-2021 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
4 # The GNU C Library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # The GNU C Library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, see
16 # <https://www.gnu.org/licenses/>.
19 # Specific makefile for stdio-common.
21 subdir := stdio-common
23 include ../Makeconfig
25 headers := stdio_ext.h printf.h bits/printf-ldbl.h bits/stdio_lim.h
27 routines := \
28 ctermid cuserid \
29 _itoa _itowa itoa-digits itoa-udigits itowa-digits \
30 vfprintf vprintf printf_fp reg-printf printf-prs printf_fphex \
31 reg-modifier reg-type \
32 printf_size fprintf printf snprintf sprintf asprintf dprintf \
33 vfwprintf vfscanf vfwscanf \
34 fscanf scanf sscanf \
35 perror psignal \
36 tmpfile tmpfile64 tmpnam tmpnam_r tempnam tempname \
37 getline getw putw \
38 remove rename renameat renameat2 \
39 flockfile ftrylockfile funlockfile \
40 isoc99_scanf isoc99_vscanf isoc99_fscanf isoc99_vfscanf isoc99_sscanf \
41 isoc99_vsscanf \
42 psiginfo gentempfd \
43 vfscanf-internal vfwscanf-internal iovfscanf \
44 vfprintf-internal vfwprintf-internal
46 aux := errlist siglist printf-parsemb printf-parsewc fxprintf
48 tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
49 temptest tst-fileno test-fwrite tst-ungetc tst-ferror \
50 xbug errnobug \
51 bug1 bug2 bug3 bug4 bug5 bug6 bug7 bug8 bug9 bug10 bug11 bug12 bug13 \
52 tfformat tiformat tllformat tstdiomisc tst-printfsz tst-wc-printf \
53 scanf1 scanf2 scanf3 scanf4 scanf5 scanf7 scanf8 scanf9 scanf10 \
54 scanf11 scanf12 tst-tmpnam tst-cookie tst-obprintf tst-sscanf \
55 tst-swprintf tst-fseek tst-fmemopen test-vfprintf tst-gets \
56 tst-perror tst-sprintf tst-rndseek tst-fdopen tst-fphex bug14 \
57 tst-popen tst-unlockedio tst-fmemopen2 tst-put-error tst-fgets \
58 tst-fwrite bug16 bug17 tst-swscanf tst-sprintf2 bug18 bug18a \
59 bug19 bug19a tst-popen2 scanf13 scanf14 scanf15 bug20 bug21 bug22 \
60 scanf16 scanf17 tst-setvbuf1 tst-grouping bug23 bug24 \
61 bug-vfprintf-nargs tst-long-dbl-fphex tst-fphex-wide tst-sprintf3 \
62 bug25 tst-printf-round bug23-2 bug23-3 bug23-4 bug26 tst-fmemopen3 \
63 tst-printf-bz18872 tst-vfprintf-width-prec tst-fmemopen4 \
64 tst-vfprintf-user-type \
65 tst-vfprintf-mbs-prec \
66 tst-scanf-round \
67 tst-renameat2 tst-bz11319 tst-bz11319-fortify2 \
68 scanf14a scanf16a \
69 tst-printf-bz25691 \
70 tst-vfprintf-width-prec-alloc \
71 tst-printf-fp-free \
72 tst-printf-fp-leak \
73 test-strerr
76 test-srcs = tst-unbputc tst-printf tst-printfsz-islongdouble
78 ifeq ($(run-built-tests),yes)
79 tests-special += $(objpfx)tst-unbputc.out $(objpfx)tst-printf.out \
80 $(objpfx)tst-printf-bz18872-mem.out \
81 $(objpfx)tst-setvbuf1-cmp.out \
82 $(objpfx)tst-vfprintf-width-prec-mem.out \
83 $(objpfx)tst-printfsz-islongdouble.out \
84 $(objpfx)tst-printf-bz25691-mem.out \
85 $(objpfx)tst-printf-fp-free-mem.out \
86 $(objpfx)tst-printf-fp-leak-mem.out
87 generated += tst-printf-bz18872.c tst-printf-bz18872.mtrace \
88 tst-printf-bz18872-mem.out \
89 tst-vfprintf-width-prec.mtrace tst-vfprintf-width-prec-mem.out \
90 tst-printf-bz25691.mtrace tst-printf-bz25691-mem.out \
91 tst-printf-fp-free.mtrace tst-printf-fp-free-mem.out \
92 tst-printf-fp-leak.mtrace tst-printf-fp-leak-mem.out
93 endif
95 tests-special += $(objpfx)tst-errno-manual.out
97 include ../Rules
99 ifeq ($(run-built-tests),yes)
100 LOCALES := de_DE.ISO-8859-1 de_DE.UTF-8 en_US.ISO-8859-1 ja_JP.EUC-JP
101 include ../gen-locales.mk
103 $(objpfx)bug14.out: $(gen-locales)
104 $(objpfx)scanf13.out: $(gen-locales)
105 $(objpfx)test-vfprintf.out: $(gen-locales)
106 $(objpfx)tst-grouping.out: $(gen-locales)
107 $(objpfx)tst-sprintf.out: $(gen-locales)
108 $(objpfx)tst-sscanf.out: $(gen-locales)
109 $(objpfx)tst-swprintf.out: $(gen-locales)
110 $(objpfx)tst-vfprintf-mbs-prec.out: $(gen-locales)
111 endif
113 tst-printf-bz18872-ENV = MALLOC_TRACE=$(objpfx)tst-printf-bz18872.mtrace \
114 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
115 tst-vfprintf-width-prec-ENV = \
116 MALLOC_TRACE=$(objpfx)tst-vfprintf-width-prec.mtrace \
117 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
118 tst-printf-bz25691-ENV = \
119 MALLOC_TRACE=$(objpfx)tst-printf-bz25691.mtrace \
120 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
121 tst-printf-fp-free-ENV = \
122 MALLOC_TRACE=$(objpfx)tst-printf-fp-free.mtrace \
123 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
124 tst-printf-fp-leak-ENV = \
125 MALLOC_TRACE=$(objpfx)tst-printf-fp-leak.mtrace \
126 LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
128 $(objpfx)tst-unbputc.out: tst-unbputc.sh $(objpfx)tst-unbputc
129 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
130 $(evaluate-test)
132 $(objpfx)tst-printf.out: tst-printf.sh $(objpfx)tst-printf
133 $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
134 $(evaluate-test)
136 $(objpfx)tst-printfsz-islongdouble.out: \
137 tst-printfsz-islongdouble.sh $(objpfx)tst-printfsz-islongdouble
138 $(SHELL) $^ '$(test-program-prefix)' $@; \
139 $(evaluate-test)
141 # We generate this source because it requires a printf invocation with
142 # 10K arguments.
143 $(objpfx)tst-printf-bz18872.c: tst-printf-bz18872.sh
144 rm -f $@ && $(BASH) $^ > $@.new && mv $@.new $@
146 $(objpfx)tst-%-mem.out: $(objpfx)tst-%.out
147 $(common-objpfx)malloc/mtrace $(objpfx)tst-$*.mtrace > $@; \
148 $(evaluate-test)
150 errlist-h = $(firstword $(wildcard $(addsuffix /errlist.h,$(sysdirs) .)))
152 $(objpfx)tst-errno-manual.out: tst-errno-manual.py \
153 $(errlist-h) \
154 $(..)manual/errno.texi
155 $(PYTHON) tst-errno-manual.py -m $(..)manual/errno.texi \
156 -e $(errlist-h) > $@; \
157 $(evaluate-test)
159 CFLAGS-vfprintf.c += -Wno-uninitialized
160 CFLAGS-vfwprintf.c += -Wno-uninitialized
162 CFLAGS-tmpfile.c += -fexceptions
163 CFLAGS-tmpfile64.c += -fexceptions
164 CFLAGS-tempname.c += -fexceptions
165 CFLAGS-psignal.c += -fexceptions
166 CFLAGS-vprintf.c += -fexceptions
167 CFLAGS-cuserid.c += -fexceptions
169 CFLAGS-vfprintf.c += -fexceptions
170 CFLAGS-fprintf.c += -fexceptions
171 CFLAGS-printf.c += -fexceptions
172 CFLAGS-vfwprintf.c += -fexceptions
173 CFLAGS-vfscanf.c += -fexceptions
174 CFLAGS-vfwscanf.c += -fexceptions
175 CFLAGS-fscanf.c += -fexceptions
176 CFLAGS-scanf.c += -fexceptions
177 CFLAGS-isoc99_vfscanf.c += -fexceptions
178 CFLAGS-isoc99_vscanf.c += -fexceptions
179 CFLAGS-isoc99_fscanf.c += -fexceptions
180 CFLAGS-isoc99_scanf.c += -fexceptions
181 CFLAGS-errlist.c += $(fno-unit-at-a-time)
182 CFLAGS-siglist.c += $(fno-unit-at-a-time)
184 # scanf14a.c and scanf16a.c test a deprecated extension which is no
185 # longer visible under most conformance levels; see the source files
186 # for more detail.
187 CFLAGS-scanf14a.c += -std=gnu89
188 CFLAGS-scanf16a.c += -std=gnu89
190 CFLAGS-bug3.c += -DOBJPFX=\"$(objpfx)\"
191 CFLAGS-bug4.c += -DOBJPFX=\"$(objpfx)\"
192 CFLAGS-bug5.c += -DOBJPFX=\"$(objpfx)\"
193 CFLAGS-test-fseek.c += -DOBJPFX=\"$(objpfx)\"
194 CFLAGS-test-popen.c += -DOBJPFX=\"$(objpfx)\"
195 CFLAGS-test_rdwr.c += -DOBJPFX=\"$(objpfx)\"
197 # tst-gets.c tests a deprecated function.
198 CFLAGS-tst-gets.c += -Wno-deprecated-declarations
200 # BZ #11319 was first fixed for regular vdprintf, then reopened because
201 # the fortified version had the same bug.
202 CFLAGS-tst-bz11319-fortify2.c += -D_FORTIFY_SOURCE=2
204 CPPFLAGS += $(libio-mtsafe)
206 $(objpfx)tst-setvbuf1.out: /dev/null $(objpfx)tst-setvbuf1
207 $(test-program-cmd) > $@ 2>&1; \
208 $(evaluate-test)
210 $(objpfx)tst-setvbuf1-cmp.out: tst-setvbuf1.expect $(objpfx)tst-setvbuf1.out
211 cmp $^ > $@; \
212 $(evaluate-test)
214 $(objpfx)tst-printf-round: $(libm)
215 $(objpfx)tst-scanf-round: $(libm)