Bug 14317 - __xpg_strerror_r not fully optimized
Summary: __xpg_strerror_r not fully optimized
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.16
: P1 normal
Target Milestone: 2.18
Assignee: Andreas Jaeger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-30 16:04 UTC by Bruno Haible
Modified: 2014-06-18 04:27 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
proposed fix (733 bytes, patch)
2012-06-30 16:08 UTC, Bruno Haible
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bruno Haible 2012-06-30 16:04:52 UTC
The implementation of __xpg_strerror_r spends time doing an strlen call,
and then potentially returning before the value is actually used.

This can be optimized.
Comment 1 Bruno Haible 2012-06-30 16:08:34 UTC
Created attachment 6502 [details]
proposed fix
Comment 2 Carlos O'Donell 2012-07-24 04:10:04 UTC
Bruno,

Fold the copyright years together e.g. 1991-2012.

If you haven't posted this to libc-alpha, please do and I'll ack.

This looks like a straight forward and useful optimization.
Comment 3 Andreas Jaeger 2012-12-01 17:05:12 UTC
I cleaned up the patch and send it to libc-alpha myself.
Comment 4 Andreas Jaeger 2012-12-03 15:38:46 UTC
Targeting for 2.18 now.
Comment 5 Andreas Jaeger 2012-12-27 21:42:42 UTC
Committed for glibc 2.18:

commit 7fffbdfff7d39cec0783e5b9381fa4093484c235
Author: 2012-12-27 Bruno Haible <bruno@clisp.org>
Date:   Thu Dec 27 22:37:39 2012 +0100

    BZ#14317: Optimze __xpg_strerror_r
    
    [BZ #14317]
    * string/xpg-strerror.c (__xpg_strerror_r): Optimize, call
    strlen only if needed.

thanks for the patch!