Skip to content

Commit 62605cb

Browse files
author
Ulrich Drepper
committed
Remove useless more "if" tests before "free".
* include/inline-hashtab.h (htab_delete): Likewise. * libio/freopen.c (freopen): Likewise. * libio/freopen64.c (freopen64): Likewise. * locale/programs/ld-collate.c (collate_read): Likewise. * misc/fstab.c (libc_freeres_fn): Likewise. * posix/glob.c (globfree): Likewise.
1 parent 4b2c85c commit 62605cb

19 files changed

+271
-24
lines changed

ChangeLog

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2008-05-26 Jim Meyering <meyering@redhat.com>
2+
3+
Remove useless more "if" tests before "free".
4+
* include/inline-hashtab.h (htab_delete): Likewise.
5+
* libio/freopen.c (freopen): Likewise.
6+
* libio/freopen64.c (freopen64): Likewise.
7+
* locale/programs/ld-collate.c (collate_read): Likewise.
8+
* misc/fstab.c (libc_freeres_fn): Likewise.
9+
* posix/glob.c (globfree): Likewise.
10+
111
2008-05-24 Ulrich Drepper <drepper@redhat.com>
212

313
* string/Makefile (strop-tests): Add memmem.

include/inline-hashtab.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ htab_delete (struct hashtab *htab)
142142
int i;
143143

144144
for (i = htab->size - 1; i >= 0; i--)
145-
if (htab->entries[i])
146-
free (htab->entries[i]);
145+
free (htab->entries[i]);
147146

148147
if (htab->free)
149148
htab->free (htab->entries);

libio/freopen.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 1993,95,96,97,98,2000,2001,2002,2003
1+
/* Copyright (C) 1993,95,96,97,98,2000,2001,2002,2003,2008
22
Free Software Foundation, Inc.
33
This file is part of the GNU C Library.
44
@@ -80,8 +80,7 @@ freopen (filename, mode, fp)
8080
if (fd != -1)
8181
{
8282
__close (fd);
83-
if (filename != NULL)
84-
free ((char *) filename);
83+
free ((char *) filename);
8584
}
8685
_IO_release_lock (fp);
8786
return result;

libio/freopen64.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 1993,1995,1996,1997,1998,2000,2001,2002, 2003
1+
/* Copyright (C) 1993,1995,1996,1997,1998,2000,2001,2002, 2003, 2008
22
Free Software Foundation, Inc.
33
This file is part of the GNU C Library.
44
@@ -64,8 +64,7 @@ freopen64 (filename, mode, fp)
6464
if (fd != -1)
6565
{
6666
__close (fd);
67-
if (filename != NULL)
68-
free ((char *) filename);
67+
free ((char *) filename);
6968
}
7069
_IO_release_lock (fp);
7170
return result;

locale/programs/ld-collate.c

+4-8
Original file line numberDiff line numberDiff line change
@@ -2961,8 +2961,7 @@ collate_read (struct linereader *ldfile, struct localedef_t *result,
29612961
else
29622962
{
29632963
col_elem_free:
2964-
if (symbol != NULL)
2965-
free ((char *) symbol);
2964+
free ((char *) symbol);
29662965
free (arg->val.str.startmb);
29672966
free (arg->val.str.startwc);
29682967
}
@@ -3142,8 +3141,7 @@ collate_read (struct linereader *ldfile, struct localedef_t *result,
31423141
arg = lr_token (ldfile, charmap, result, repertoire, verbose);
31433142
if (arg->tok != tok_bsymbol)
31443143
{
3145-
if (newname != NULL)
3146-
free ((char *) newname);
3144+
free ((char *) newname);
31473145
goto err_label;
31483146
}
31493147

@@ -3157,10 +3155,8 @@ collate_read (struct linereader *ldfile, struct localedef_t *result,
31573155
"LC_COLLATE");
31583156

31593157
sym_equiv_free:
3160-
if (newname != NULL)
3161-
free ((char *) newname);
3162-
if (symname != NULL)
3163-
free ((char *) symname);
3158+
free ((char *) newname);
3159+
free ((char *) symname);
31643160
break;
31653161
}
31663162
if (symname == NULL)

misc/fstab.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
1+
/* Copyright (C) 1995, 1996, 1997, 1998, 2000, 2008
2+
Free Software Foundation, Inc.
23
This file is part of the GNU C Library.
34
45
The GNU C Library is free software; you can redistribute it and/or
@@ -185,6 +186,5 @@ libc_freeres_fn (fstab_free)
185186
char *buffer;
186187

187188
buffer = fstab_state.fs_buffer;
188-
if (buffer != NULL)
189-
free ((void *) buffer);
189+
free ((void *) buffer);
190190
}

nptl/ChangeLog

+22
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
2008-05-23 Paul Pluzhnikov <ppluzhnikov@google.com>
2+
3+
* sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S: Add
4+
cfi directives.
5+
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: Likewise.
6+
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: Likewise.
7+
* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S: Likewise.
8+
* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_unlock.S: Likewise.
9+
* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_wrlock.S: Likewise.
10+
* sysdeps/unix/sysv/linux/i386/i486/sem_post.S: Likewise.
11+
12+
2008-05-22 Paul Pluzhnikov <ppluzhnikov@google.com>
13+
14+
* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S: Add
15+
cfi directives.
16+
* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
17+
Likewise.
18+
* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S:
19+
Likewise.
20+
* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S:
21+
Likewise.
22+
123
2008-05-26 Ulrich Drepper <drepper@redhat.com>
224

325
* tst-typesizes.c: Explicitly check __SIZEOF_PTHREAD_* constants.

nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S

+19
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
.type pthread_barrier_wait,@function
2828
.align 16
2929
pthread_barrier_wait:
30+
cfi_startproc
3031
pushl %ebx
32+
cfi_adjust_cfa_offset(4)
33+
cfi_offset(%ebx, -8)
3134

3235
movl 8(%esp), %ebx
3336

@@ -45,6 +48,8 @@ pthread_barrier_wait:
4548

4649
/* There are more threads to come. */
4750
pushl %esi
51+
cfi_adjust_cfa_offset(4)
52+
cfi_offset(%esi, -12)
4853

4954
#if CURR_EVENT == 0
5055
movl (%ebx), %edx
@@ -101,9 +106,16 @@ pthread_barrier_wait:
101106
10: movl %esi, %eax /* != PTHREAD_BARRIER_SERIAL_THREAD */
102107

103108
popl %esi
109+
cfi_adjust_cfa_offset(-4)
110+
cfi_restore(%esi)
104111
popl %ebx
112+
cfi_adjust_cfa_offset(-4)
113+
cfi_restore(%ebx)
105114
ret
106115

116+
cfi_adjust_cfa_offset(4)
117+
cfi_offset(%ebx, -8)
118+
107119
/* The necessary number of threads arrived. */
108120
3:
109121
#if CURR_EVENT == 0
@@ -140,8 +152,12 @@ pthread_barrier_wait:
140152
5: orl $-1, %eax /* == PTHREAD_BARRIER_SERIAL_THREAD */
141153

142154
popl %ebx
155+
cfi_adjust_cfa_offset(-4)
156+
cfi_restore(%ebx)
143157
ret
144158

159+
cfi_adjust_cfa_offset(4)
160+
cfi_offset(%ebx, -8)
145161
1: movl PRIVATE(%ebx), %ecx
146162
leal MUTEX(%ebx), %edx
147163
xorl $LLL_SHARED, %ecx
@@ -154,6 +170,8 @@ pthread_barrier_wait:
154170
call __lll_unlock_wake
155171
jmp 5b
156172

173+
cfi_adjust_cfa_offset(4)
174+
cfi_offset(%esi, -12)
157175
6: movl PRIVATE(%ebx), %ecx
158176
leal MUTEX(%ebx), %eax
159177
xorl $LLL_SHARED, %ecx
@@ -165,4 +183,5 @@ pthread_barrier_wait:
165183
xorl $LLL_SHARED, %ecx
166184
call __lll_unlock_wake
167185
jmp 10b
186+
cfi_endproc
168187
.size pthread_barrier_wait,.-pthread_barrier_wait

nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S

+36-1
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,19 @@
3232
.type __pthread_cond_broadcast, @function
3333
.align 16
3434
__pthread_cond_broadcast:
35-
35+
cfi_startproc
3636
pushl %ebx
37+
cfi_adjust_cfa_offset(4)
3738
pushl %esi
39+
cfi_adjust_cfa_offset(4)
3840
pushl %edi
41+
cfi_adjust_cfa_offset(4)
3942
pushl %ebp
43+
cfi_adjust_cfa_offset(4)
44+
cfi_offset(%ebx, -8)
45+
cfi_offset(%esi, -12)
46+
cfi_offset(%edi, -16)
47+
cfi_offset(%ebp, -20)
4048

4149
movl 20(%esp), %ebx
4250

@@ -114,11 +122,24 @@ __pthread_cond_broadcast:
114122

115123
10: xorl %eax, %eax
116124
popl %ebp
125+
cfi_adjust_cfa_offset(-4)
126+
cfi_restore(%ebp)
117127
popl %edi
128+
cfi_adjust_cfa_offset(-4)
129+
cfi_restore(%edi)
118130
popl %esi
131+
cfi_adjust_cfa_offset(-4)
132+
cfi_restore(%esi)
119133
popl %ebx
134+
cfi_adjust_cfa_offset(-4)
135+
cfi_restore(%ebx)
120136
ret
121137

138+
cfi_adjust_cfa_offset(16)
139+
cfi_offset(%ebx, -8)
140+
cfi_offset(%esi, -12)
141+
cfi_offset(%edi, -16)
142+
cfi_offset(%ebp, -20)
122143
.align 16
123144
/* Unlock. */
124145
4: LOCK
@@ -127,11 +148,24 @@ __pthread_cond_broadcast:
127148

128149
6: xorl %eax, %eax
129150
popl %ebp
151+
cfi_adjust_cfa_offset(-4)
152+
cfi_restore(%ebp)
130153
popl %edi
154+
cfi_adjust_cfa_offset(-4)
155+
cfi_restore(%edi)
131156
popl %esi
157+
cfi_adjust_cfa_offset(-4)
158+
cfi_restore(%esi)
132159
popl %ebx
160+
cfi_adjust_cfa_offset(-4)
161+
cfi_restore(%ebx)
133162
ret
134163

164+
cfi_adjust_cfa_offset(16)
165+
cfi_offset(%ebx, -8)
166+
cfi_offset(%esi, -12)
167+
cfi_offset(%edi, -16)
168+
cfi_offset(%ebp, -20)
135169
/* Initial locking failed. */
136170
1:
137171
#if cond_lock == 0
@@ -199,6 +233,7 @@ __pthread_cond_broadcast:
199233
movl $SYS_futex, %eax
200234
ENTER_KERNEL
201235
jmp 10b
236+
cfi_endproc
202237
.size __pthread_cond_broadcast, .-__pthread_cond_broadcast
203238
versioned_symbol (libpthread, __pthread_cond_broadcast, pthread_cond_broadcast,
204239
GLIBC_2_3_2)

nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S

+23
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@
3333
.align 16
3434
__pthread_cond_signal:
3535

36+
cfi_startproc
3637
pushl %ebx
38+
cfi_adjust_cfa_offset(4)
3739
pushl %edi
40+
cfi_adjust_cfa_offset(4)
41+
cfi_offset(%ebx, -8)
42+
cfi_offset(%edi, -12)
3843

3944
movl 12(%esp), %edi
4045

@@ -69,7 +74,12 @@ __pthread_cond_signal:
6974

7075
/* Wake up one thread. */
7176
pushl %esi
77+
cfi_adjust_cfa_offset(4)
7278
pushl %ebp
79+
cfi_adjust_cfa_offset(4)
80+
cfi_offset(%esi, -16)
81+
cfi_offset(%ebp, -20)
82+
7383
#if FUTEX_PRIVATE_FLAG > 255
7484
xorl %ecx, %ecx
7585
#endif
@@ -91,7 +101,11 @@ __pthread_cond_signal:
91101
ENTER_KERNEL */
92102
int $0x80
93103
popl %ebp
104+
cfi_adjust_cfa_offset(-4)
105+
cfi_restore(%ebp)
94106
popl %esi
107+
cfi_adjust_cfa_offset(-4)
108+
cfi_restore(%esi)
95109

96110
/* For any kind of error, we try again with WAKE.
97111
The general test also covers running on old kernels. */
@@ -100,9 +114,17 @@ __pthread_cond_signal:
100114

101115
6: xorl %eax, %eax
102116
popl %edi
117+
cfi_adjust_cfa_offset(-4)
118+
cfi_restore(%edi)
103119
popl %ebx
120+
cfi_adjust_cfa_offset(-4)
121+
cfi_restore(%ebx)
104122
ret
105123

124+
cfi_adjust_cfa_offset(8)
125+
cfi_offset(%ebx, -8)
126+
cfi_offset(%edi, -12)
127+
106128
7: /* %ecx should be either FUTEX_WAKE_OP or
107129
FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG from the previous syscall. */
108130
xorl $(FUTEX_WAKE ^ FUTEX_WAKE_OP), %ecx
@@ -152,6 +174,7 @@ __pthread_cond_signal:
152174
call __lll_lock_wait
153175
jmp 2b
154176

177+
cfi_endproc
155178
.size __pthread_cond_signal, .-__pthread_cond_signal
156179
versioned_symbol (libpthread, __pthread_cond_signal, pthread_cond_signal,
157180
GLIBC_2_3_2)

nptl/sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_rdlock.S

+13
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@
3030
.type __pthread_rwlock_rdlock,@function
3131
.align 16
3232
__pthread_rwlock_rdlock:
33+
cfi_startproc
3334
pushl %esi
35+
cfi_adjust_cfa_offset(4)
3436
pushl %ebx
37+
cfi_adjust_cfa_offset(4)
38+
cfi_offset(%esi, -8)
39+
cfi_offset(%ebx, -12)
3540

3641
xorl %esi, %esi
3742
movl 12(%esp), %ebx
@@ -113,9 +118,16 @@ __pthread_rwlock_rdlock:
113118

114119
movl %edx, %eax
115120
popl %ebx
121+
cfi_adjust_cfa_offset(-4)
122+
cfi_restore(%ebx)
116123
popl %esi
124+
cfi_adjust_cfa_offset(-4)
125+
cfi_restore(%esi)
117126
ret
118127

128+
cfi_adjust_cfa_offset(8)
129+
cfi_offset(%esi, -8)
130+
cfi_offset(%ebx, -12)
119131
1:
120132
#if MUTEX == 0
121133
movl %ebx, %edx
@@ -171,6 +183,7 @@ __pthread_rwlock_rdlock:
171183
movzbl PSHARED(%ebx), %ecx
172184
call __lll_lock_wait
173185
jmp 13b
186+
cfi_endproc
174187
.size __pthread_rwlock_rdlock,.-__pthread_rwlock_rdlock
175188

176189
.globl pthread_rwlock_rdlock

0 commit comments

Comments
 (0)