Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.1:Update
cvs
cvs-useless-asnprintf.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File cvs-useless-asnprintf.diff of Package cvs
--- m4/gnulib.m4 +++ m4/gnulib.m4 @@ -80,7 +80,6 @@ gl_TIMESPEC gl_FUNC_TZSET_CLOBBER gl_FUNC_GLIBC_UNLOCKED_IO - gl_FUNC_VASNPRINTF gl_FUNC_VASPRINTF gl_XALLOC gl_XGETCWD --- src/error.c +++ src/error.c @@ -111,24 +111,14 @@ int save_errno = errno; /* Various buffers we attempt to use to generate the error message. */ - char statbuf[256]; char *buf; size_t length; - char statbuf2[384]; char *buf2; - char statcmdbuf[32]; - char *cmdbuf; - char *emptybuf = ""; - - /* Initialize these to avoid a lot of special case error handling. */ - buf = statbuf; - buf2 = statbuf2; - cmdbuf = emptybuf; + char *cmdbuf = 0; /* Expand the message the user passed us. */ va_start (args, message); - length = sizeof (statbuf); - buf = vasnprintf (statbuf, &length, message, args); + length = vasprintf (&buf, message, args); va_end (args); if (!buf) goto memerror; @@ -141,21 +131,19 @@ */ if (cvs_cmd_name) { - length = sizeof (statcmdbuf); - cmdbuf = asnprintf (statcmdbuf, &length, " %s%s%s", - status ? "[" : "", - cvs_cmd_name, - status ? " aborted]" : ""); + length = asprintf (&cmdbuf, " %s%s%s", + status ? "[" : "", + cvs_cmd_name, + status ? " aborted]" : ""); /* Else cmdbuf still = emptybuf. */ if (!cmdbuf) goto memerror; } /* Else cmdbuf still = emptybuf. */ /* Now put it all together. */ - length = sizeof (statbuf2); - buf2 = asnprintf (statbuf2, &length, "%s%s: %s%s%s\n", - program_name, cmdbuf, buf, - errnum ? ": " : "", errnum ? strerror (errnum) : ""); + length = asprintf (&buf2, "%s%s: %s%s%s\n", + program_name, cmdbuf ? cmdbuf : "", buf, + errnum ? ": " : "", errnum ? strerror (errnum) : ""); if (!buf2) goto memerror; /* Send the final message to the client or log it. */ @@ -166,9 +154,9 @@ exit (EXIT_FAILURE); /* Free anything we may have allocated. */ - if (buf != statbuf) free (buf); - if (buf2 != statbuf2) free (buf2); - if (cmdbuf != statcmdbuf && cmdbuf != emptybuf) free (cmdbuf); + free (buf); + free (buf2); + free (cmdbuf); /* Restore errno per our charter. */ errno = save_errno; --- src/subr.c +++ src/subr.c @@ -1881,8 +1881,8 @@ char *result; va_start (args, format); - result = vasnprintf (resultbuf, lengthp, format, args); - if (result == NULL) + *lengthp = vasprintf (&result, format, args); + if (*lengthp < 0) error (1, errno, "Failed to write to string."); va_end (args);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor