[asterisk-commits] murf: branch 1.6.0 r147809 - in /branches/1.6.0: ./ channels/ doc/ include/ i...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 9 09:56:52 CDT 2008


Author: murf
Date: Thu Oct  9 09:56:51 2008
New Revision: 147809

URL: http://svn.digium.com/view/asterisk?view=rev&rev=147809
Log:
Merged revisions 147807 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r147807 | murf | 2008-10-09 08:17:33 -0600 (Thu, 09 Oct 2008) | 15 lines

(closes issue #13557)
Reported by: nickpeirson
Patches:
      pbx.c.patch uploaded by nickpeirson (license 579)
      replace_bzero+bcopy.patch uploaded by nickpeirson (license 579)
Tested by: nickpeirson, murf

1. replaced all refs to bzero and bcopy to memset and memmove instead.
2. added a note to the CODING-GUIDELINES
3. add two macros to asterisk.h to prevent bzero, bcopy from creeping
   back into the source
4. removed bzero from configure, configure.ac, autoconfig.h.in



........

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/channels/chan_iax2.c
    branches/1.6.0/channels/chan_oss.c
    branches/1.6.0/channels/console_gui.c
    branches/1.6.0/channels/console_video.c
    branches/1.6.0/channels/vcodecs.c
    branches/1.6.0/configure
    branches/1.6.0/configure.ac
    branches/1.6.0/doc/CODING-GUIDELINES
    branches/1.6.0/include/asterisk.h
    branches/1.6.0/include/asterisk/autoconfig.h.in
    branches/1.6.0/main/astobj2.c
    branches/1.6.0/main/cli.c
    branches/1.6.0/main/config.c
    branches/1.6.0/main/pbx.c
    branches/1.6.0/main/rtp.c
    branches/1.6.0/main/translate.c
    branches/1.6.0/utils/extconf.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/channels/chan_iax2.c?view=diff&rev=147809&r1=147808&r2=147809
==============================================================================
--- branches/1.6.0/channels/chan_iax2.c (original)
+++ branches/1.6.0/channels/chan_iax2.c Thu Oct  9 09:56:51 2008
@@ -6483,7 +6483,7 @@
 	
 	memset(&ied, 0, sizeof(ied));
 	if (ies->apparent_addr)
-		bcopy(ies->apparent_addr, &new, sizeof(new));
+		memmove(&new, ies->apparent_addr, sizeof(new));
 	if (ies->callno)
 		newcall = ies->callno;
 	if (!newcall || !new.sin_addr.s_addr || !new.sin_port) {
@@ -6619,7 +6619,7 @@
 
 	memset(&us, 0, sizeof(us));
 	if (ies->apparent_addr)
-		bcopy(ies->apparent_addr, &us, sizeof(us));
+		memmove(&us, ies->apparent_addr, sizeof(us));
 	if (ies->username)
 		ast_copy_string(peer, ies->username, sizeof(peer));
 	if (ies->refresh)

Modified: branches/1.6.0/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/channels/chan_oss.c?view=diff&rev=147809&r1=147808&r2=147809
==============================================================================
--- branches/1.6.0/channels/chan_oss.c (original)
+++ branches/1.6.0/channels/chan_oss.c Thu Oct  9 09:56:51 2008
@@ -701,7 +701,7 @@
 
 	/* XXX can be simplified returning &ast_null_frame */
 	/* prepare a NULL frame in case we don't have enough data to return */
-	bzero(f, sizeof(struct ast_frame));
+	memset(f, '\0', sizeof(struct ast_frame));
 	f->frametype = AST_FRAME_NULL;
 	f->src = oss_tech.type;
 

Modified: branches/1.6.0/channels/console_gui.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/channels/console_gui.c?view=diff&rev=147809&r1=147808&r2=147809
==============================================================================
--- branches/1.6.0/channels/console_gui.c (original)
+++ branches/1.6.0/channels/console_gui.c Thu Oct  9 09:56:51 2008
@@ -135,7 +135,7 @@
 		if (gui->win[i].bmp)
 			SDL_FreeYUVOverlay(gui->win[i].bmp);
 	}
-	bzero(gui, sizeof(gui));
+	memset(gui, '\0', sizeof(gui));
 	ast_free(gui);
 	SDL_Quit();
 	return NULL;
@@ -182,7 +182,7 @@
 	bmp = gui->win[out].bmp;
 	SDL_LockYUVOverlay(bmp);
 	/* output picture info - this is sdl, YUV420P */
-	bzero(&p_out, sizeof(p_out));
+	memset(&p_out, '\0', sizeof(p_out));
 	p_out.data[0] = bmp->pixels[0];
 	p_out.data[1] = bmp->pixels[1];
 	p_out.data[2] = bmp->pixels[2];
@@ -943,7 +943,7 @@
 		return 0;
 
 	s1[0] = s2[0] = '\0';
-	bzero(&e, sizeof(e));
+	memset(&e, '\0', sizeof(e));
 	i = sscanf(val, "%14s %14s %d %d %d %d %d",
                 s1, s2, &e.x0, &e.y0, &e.x1, &e.y1, &e.h);
 

Modified: branches/1.6.0/channels/console_video.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/channels/console_video.c?view=diff&rev=147809&r1=147808&r2=147809
==============================================================================
--- branches/1.6.0/channels/console_video.c (original)
+++ branches/1.6.0/channels/console_video.c Thu Oct  9 09:56:51 2008
@@ -231,7 +231,7 @@
 
 	if (b->data && b->size)
 		ast_free(b->data);
-	bzero(b, sizeof(*b));
+	memset(b, '\0', sizeof(*b));
 	/* restore some fields */
 	b->w = x.w;
 	b->h = x.h;
@@ -472,7 +472,7 @@
 	int len = b->w;		/* Y linesize, bytes */
 	int luv = b->w/2;	/* U/V linesize, bytes */
 
-	bzero(p, sizeof(*p));
+	memset(p, '\0', sizeof(*p));
 	switch (b->pix_fmt) {
 	case PIX_FMT_RGB555:
 	case PIX_FMT_RGB565:

Modified: branches/1.6.0/channels/vcodecs.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/channels/vcodecs.c?view=diff&rev=147809&r1=147808&r2=147809
==============================================================================
--- branches/1.6.0/channels/vcodecs.c (original)
+++ branches/1.6.0/channels/vcodecs.c Thu Oct  9 09:56:51 2008
@@ -204,7 +204,7 @@
 		if ( x == 0) {	/* new line */
 			if (i != 0)
 				ast_log(LOG_WARNING, "%s\n", buf);
-			bzero(buf, sizeof(buf));
+			memset(buf, '\0', sizeof(buf));
 			sprintf(buf, "%04x: ", i);
 		}
 		sprintf(buf + 6 + x*3, "%02x ", b->data[i]);
@@ -504,7 +504,7 @@
 		}
 	}
 	if (srclen != 0)	/* update b with leftover data */
-		bcopy(src, b->data, srclen);
+		memmove(b->data, src, srclen);
 	b->used = srclen;
 	b->ebit = 0;
 	return full_frame;
@@ -582,7 +582,7 @@
 	if (len < H263_MIN_LEN)	/* unreasonably small */
 		return NULL;
 
-	bzero(h263_hdr, sizeof(h263_hdr));
+	memset(h263_hdr, '\0', sizeof(h263_hdr));
 	/* Now set the header bytes. Only type A by now,
 	 * and h[0] = h[2] = h[3] = 0 by default.
 	 * PTYPE starts 30 bits in the picture, so the first useful
@@ -647,7 +647,7 @@
 
 		if (!f)
 			break;
-		bcopy(h, f->data, 4);	/* copy the h263 header */
+		memmove(f->data.ptr, h, 4);	/* copy the h263 header */
 		/* XXX to do: if not aligned, fix sbit and ebit,
 		 * then move i back by 1 for the next frame
 		 */
@@ -737,7 +737,7 @@
 	if (len < H261_MIN_LEN)	/* unreasonably small */
 		return NULL;
 
-	bzero(h261_hdr, sizeof(h261_hdr));
+	memset(h261_hdr, '\0', sizeof(h261_hdr));
 
 	/* Similar to the code in h263_encap, but the marker there is longer.
 	 * Start a few bytes within the bitstream to avoid hitting the marker
@@ -801,7 +801,7 @@
 			break;
 		/* recompute header with I=0, V=1 */
 		h[0] = ( (sbit & 7) << 5 ) | ( (ebit & 7) << 2 ) | 1;
-		bcopy(h, f->data, 4);	/* copy the h261 header */
+		memmove(f->data.ptr, h, 4);	/* copy the h261 header */
 		if (ebit)	/* not aligned, restart from previous byte */
 			i--;
 		sbit = (8 - ebit) & 7;
@@ -902,7 +902,7 @@
 	}
 	datalen -= ret;
 	if (datalen > 0)	/* update b with leftover bytes */
-		bcopy(b->data + ret, b->data, datalen);
+		memmove(b->data, b->data + ret, datalen);
 	b->used = datalen;
 	b->ebit = 0;
 	return full_frame;

Modified: branches/1.6.0/configure.ac
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/configure.ac?view=diff&rev=147809&r1=147808&r2=147809
==============================================================================
--- branches/1.6.0/configure.ac (original)
+++ branches/1.6.0/configure.ac Thu Oct  9 09:56:51 2008
@@ -311,7 +311,7 @@
 AC_FUNC_STRTOD
 AC_FUNC_UTIME_NULL
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([asprintf atexit bzero dup2 endpwent ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf])
+AC_CHECK_FUNCS([asprintf atexit dup2 endpwent ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf])
 
 AC_CHECK_FUNCS([glob])
 

Modified: branches/1.6.0/doc/CODING-GUIDELINES
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/doc/CODING-GUIDELINES?view=diff&rev=147809&r1=147808&r2=147809
==============================================================================
--- branches/1.6.0/doc/CODING-GUIDELINES (original)
+++ branches/1.6.0/doc/CODING-GUIDELINES Thu Oct  9 09:56:51 2008
@@ -373,6 +373,12 @@
 * Use of functions
 ------------------
 
+For the sake of uclibc, do not use index, bcopy or bzero; use 
+strchr(), memset(), and memmove() instead. uclibc can be configured
+to supply these functions, but we can save these users
+time and consternation if we abstain from using these
+functions.
+
 When making applications, always ast_strdupa(data) to a local pointer if
 you intend to parse the incoming data string.
 

Modified: branches/1.6.0/include/asterisk.h
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/include/asterisk.h?view=diff&rev=147809&r1=147808&r2=147809
==============================================================================
--- branches/1.6.0/include/asterisk.h (original)
+++ branches/1.6.0/include/asterisk.h Thu Oct  9 09:56:51 2008
@@ -178,4 +178,7 @@
 struct ast_variable;
 struct ast_str;
 
+#define bzero  0x__dont_use_bzero__use_memset_instead""
+#define bcopy  0x__dont_use_bcopy__use_memmove_instead()
+
 #endif /* _ASTERISK_H */

Modified: branches/1.6.0/include/asterisk/autoconfig.h.in
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/include/asterisk/autoconfig.h.in?view=diff&rev=147809&r1=147808&r2=147809
==============================================================================
--- branches/1.6.0/include/asterisk/autoconfig.h.in (original)
+++ branches/1.6.0/include/asterisk/autoconfig.h.in Thu Oct  9 09:56:51 2008
@@ -118,9 +118,6 @@
 
 /* Define to 1 if byteswap.h macros are available. */
 #undef HAVE_BYTESWAP_H
-
-/* Define to 1 if you have the `bzero' function. */
-#undef HAVE_BZERO
 
 /* Define this to indicate the ${CAP_DESCRIP} library */
 #undef HAVE_CAP

Modified: branches/1.6.0/main/astobj2.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/astobj2.c?view=diff&rev=147809&r1=147808&r2=147809
==============================================================================
--- branches/1.6.0/main/astobj2.c (original)
+++ branches/1.6.0/main/astobj2.c Thu Oct  9 09:56:51 2008
@@ -194,7 +194,7 @@
 		/* for safety, zero-out the astobj2 header and also the
 		 * first word of the user-data, which we make sure is always
 		 * allocated. */
-		bzero(obj, sizeof(struct astobj2 *) + sizeof(void *) );
+		memset(obj, '\0', sizeof(struct astobj2 *) + sizeof(void *) );
 		free(obj);
 	}
 

Modified: branches/1.6.0/main/cli.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/cli.c?view=diff&rev=147809&r1=147808&r2=147809
==============================================================================
--- branches/1.6.0/main/cli.c (original)
+++ branches/1.6.0/main/cli.c Thu Oct  9 09:56:51 2008
@@ -1426,7 +1426,7 @@
 		e->_full_cmd = NULL;
 		if (e->handler) {
 			/* this is a new-style entry. Reset fields and free memory. */
-			bzero((char **)(e->cmda), sizeof(e->cmda));
+			memset((char **)(e->cmda), '\0', sizeof(e->cmda));
 			ast_free(e->command);
 			e->command = NULL;
 			e->usage = NULL;
@@ -1444,7 +1444,7 @@
 	char **dst = (char **)e->cmda;	/* need to cast as the entry is readonly */
 	char *s;
 
-	bzero (&a, sizeof(a));
+	memset(&a, '\0', sizeof(a));
 	e->handler(e, CLI_INIT, &a);
 	/* XXX check that usage and command are filled up */
 	s = ast_skip_blanks(e->command);

Modified: branches/1.6.0/main/config.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/config.c?view=diff&rev=147809&r1=147808&r2=147809
==============================================================================
--- branches/1.6.0/main/config.c (original)
+++ branches/1.6.0/main/config.c Thu Oct  9 09:56:51 2008
@@ -2269,7 +2269,7 @@
 		struct hostent *hp;
 		struct ast_hostent ahp;
 
-		bzero(&_sa_buf, sizeof(_sa_buf)); /* clear buffer */
+		memset(&_sa_buf, '\0', sizeof(_sa_buf)); /* clear buffer */
 		/* duplicate the string to strip away the :port */
 		port = ast_strdupa(arg);
 		buf = strsep(&port, ":");

Modified: branches/1.6.0/main/pbx.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/pbx.c?view=diff&rev=147809&r1=147808&r2=147809
==============================================================================
--- branches/1.6.0/main/pbx.c (original)
+++ branches/1.6.0/main/pbx.c Thu Oct  9 09:56:51 2008
@@ -1719,7 +1719,7 @@
 		return 0x40000;	/* XXX make this entry go last... */
 	}
 
-	bzero(chars, sizeof(chars));	/* clear all chars in the set */
+	memset(chars, '\0', sizeof(chars));	/* clear all chars in the set */
 	for (; *p < end  ; (*p)++) {
 		unsigned char c1, c2;	/* first-last char in range */
 		c1 = (unsigned char)((*p)[0]);

Modified: branches/1.6.0/main/rtp.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/rtp.c?view=diff&rev=147809&r1=147808&r2=147809
==============================================================================
--- branches/1.6.0/main/rtp.c (original)
+++ branches/1.6.0/main/rtp.c Thu Oct  9 09:56:51 2008
@@ -625,7 +625,7 @@
 		res = ast_select(s + 1, &rfds, NULL, NULL, &to);
 		if (res <= 0)	/* timeout or error */
 			continue;
-		bzero(&src, sizeof(src));
+		memset(&src, '\0', sizeof(src));
 		srclen = sizeof(src);
 		/* XXX pass -1 in the size, because stun_handle_packet might
 		 * write past the end of the buffer.
@@ -637,7 +637,7 @@
 				retry, res);
 			continue;
 		}
-		bzero(answer, sizeof(struct sockaddr_in));
+		memset(answer, '\0', sizeof(struct sockaddr_in));
 		stun_handle_packet(s, &src, reply_buf, res,
 			stun_get_mapped, answer);
 		res = 0; /* signal regular exit */

Modified: branches/1.6.0/main/translate.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/translate.c?view=diff&rev=147809&r1=147808&r2=147809
==============================================================================
--- branches/1.6.0/main/translate.c (original)
+++ branches/1.6.0/main/translate.c Thu Oct  9 09:56:51 2008
@@ -451,7 +451,7 @@
 
 	ast_debug(1, "Resetting translation matrix\n");
 
-	bzero(tr_matrix, sizeof(tr_matrix));
+	memset(tr_matrix, '\0', sizeof(tr_matrix));
 
 	/* first, compute all direct costs */
 	AST_RWLIST_TRAVERSE(&translators, t, list) {

Modified: branches/1.6.0/utils/extconf.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/utils/extconf.c?view=diff&rev=147809&r1=147808&r2=147809
==============================================================================
--- branches/1.6.0/utils/extconf.c (original)
+++ branches/1.6.0/utils/extconf.c Thu Oct  9 09:56:51 2008
@@ -4406,7 +4406,7 @@
 		return 0x40000;	/* XXX make this entry go last... */
 	}
 
-	bzero(chars, sizeof(chars));	/* clear all chars in the set */
+	memset(chars, '\0', sizeof(chars));	/* clear all chars in the set */
 	for (; *p < end  ; (*p)++) {
 		unsigned char c1, c2;	/* first-last char in range */
 		c1 = (unsigned char)((*p)[0]);




More information about the asterisk-commits mailing list