aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--channels/chan_iax2.c4
-rw-r--r--channels/chan_oss.c2
-rw-r--r--channels/chan_usbradio.c8
-rw-r--r--channels/console_gui.c8
-rw-r--r--channels/console_video.c4
-rw-r--r--channels/vcodecs.c14
-rwxr-xr-xconfigure15
-rw-r--r--configure.ac2
-rw-r--r--doc/CODING-GUIDELINES6
-rw-r--r--include/asterisk.h3
-rw-r--r--include/asterisk/autoconfig.h.in3
-rw-r--r--main/astobj2.c2
-rw-r--r--main/cli.c4
-rw-r--r--main/config.c2
-rw-r--r--main/pbx.c2
-rw-r--r--main/rtp.c4
-rw-r--r--main/translate.c2
-rw-r--r--utils/extconf.c2
18 files changed, 48 insertions, 39 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 116c13ace..63e2d10f2 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -6590,7 +6590,7 @@ static int try_transfer(struct chan_iax2_pvt *pvt, struct iax_ies *ies)
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) {
@@ -6728,7 +6728,7 @@ static int iax2_ack_registry(struct iax_ies *ies, struct sockaddr_in *sin, int c
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)
diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index ae4137c64..ddaa2efde 100644
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -701,7 +701,7 @@ static struct ast_frame *oss_read(struct ast_channel *c)
/* 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;
diff --git a/channels/chan_usbradio.c b/channels/chan_usbradio.c
index f3196e30c..a5daebe7c 100644
--- a/channels/chan_usbradio.c
+++ b/channels/chan_usbradio.c
@@ -1411,7 +1411,7 @@ static void send_sound(struct chan_usbradio_pvt *o)
l = FRAME_SIZE - ofs;
if (l > s->datalen - start) /* don't overflow the source */
l = s->datalen - start;
- bcopy(s->data + start, myframe + ofs, l * 2);
+ memmove(myframe + ofs, s->data + start, l * 2);
if (0)
ast_log(LOG_WARNING, "send_sound sound %d/%d of %d into %d\n", l_sampsent, l, s->samplen, ofs);
l_sampsent += l;
@@ -1422,14 +1422,14 @@ static void send_sound(struct chan_usbradio_pvt *o)
if (l > 0) {
if (l > FRAME_SIZE - ofs)
l = FRAME_SIZE - ofs;
- bcopy(silence, myframe + ofs, l * 2);
+ memmove(myframe + ofs, silence, l * 2);
l_sampsent += l;
} else { /* silence is over, restart sound if loop */
if (s->repeat == 0) { /* last block */
o->cursound = -1;
o->nosound = 0; /* allow audio data */
if (ofs < FRAME_SIZE) /* pad with silence */
- bcopy(silence, myframe + ofs, (FRAME_SIZE - ofs) * 2);
+ memmove(myframe + ofs, silence, (FRAME_SIZE - ofs) * 2);
}
l_sampsent = 0;
}
@@ -1813,7 +1813,7 @@ static struct ast_frame *usbradio_read(struct ast_channel *c)
}
/* 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 = usbradio_tech.type;
diff --git a/channels/console_gui.c b/channels/console_gui.c
index 480f6f1ce..c3ced5e49 100644
--- a/channels/console_gui.c
+++ b/channels/console_gui.c
@@ -204,7 +204,7 @@ static struct gui_info *cleanup_sdl(struct gui_info *gui, int device_num)
if (gui->win[i].bmp)
SDL_FreeYUVOverlay(gui->win[i].bmp);
}
- bzero(gui, sizeof(gui));
+ memset(gui, '\0', sizeof(gui));
/* deallocates the space allocated for the keypad message boards */
if (gui->bd_dialed)
@@ -290,7 +290,7 @@ static void show_frame(struct video_desc *env, int out)
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];
@@ -1358,7 +1358,7 @@ static void sdl_setup(struct video_desc *env)
FocusChangeMask | PropertyChangeMask |
ColormapChangeMask | OwnerGrabButtonMask;
- bzero(&attr, sizeof(attr));
+ memset(&attr, '\0', sizeof(attr));
XGetWindowAttributes(SDL_Display, win, &attr);
/* the following events can be delivered only to one client.
@@ -1565,7 +1565,7 @@ static int keypad_cfg_read(struct gui_info *gui, const char *val)
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);
diff --git a/channels/console_video.c b/channels/console_video.c
index a7735a665..88bf807d5 100644
--- a/channels/console_video.c
+++ b/channels/console_video.c
@@ -272,7 +272,7 @@ void fbuf_free(struct fbuf_t *b)
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;
@@ -587,7 +587,7 @@ static AVPicture *fill_pict(struct fbuf_t *b, AVPicture *p)
int luv = b->w/2; /* U/V linesize, bytes */
int sample_size = 1;
- bzero(p, sizeof(*p));
+ memset(p, '\0', sizeof(*p));
switch (b->pix_fmt) {
case PIX_FMT_RGB555:
case PIX_FMT_RGB565:
diff --git a/channels/vcodecs.c b/channels/vcodecs.c
index 90f7258b1..ecb7a8c71 100644
--- a/channels/vcodecs.c
+++ b/channels/vcodecs.c
@@ -204,7 +204,7 @@ void dump_buf(struct fbuf_t *b)
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 @@ static int ffmpeg_decode(struct video_dec_desc *v, struct fbuf_t *b)
}
}
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 @@ static struct ast_frame *h263_encap(struct fbuf_t *b, int mtu,
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 @@ static struct ast_frame *h263_encap(struct fbuf_t *b, int mtu,
if (!f)
break;
- bcopy(h, f->data.ptr, 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 @@ static struct ast_frame *h261_encap(struct fbuf_t *b, int mtu,
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 @@ static struct ast_frame *h261_encap(struct fbuf_t *b, int mtu,
break;
/* recompute header with I=0, V=1 */
h[0] = ( (sbit & 7) << 5 ) | ( (ebit & 7) << 2 ) | 1;
- bcopy(h, f->data.ptr, 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 @@ static int mpeg4_decode(struct video_dec_desc *v, struct fbuf_t *b)
}
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;
diff --git a/configure b/configure
index 3cf7e49f6..5145d3bde 100755
--- a/configure
+++ b/configure
@@ -12951,11 +12951,13 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
-#include <stdio.h>
+#include <sys/types.h> /* for off_t */
+ #include <stdio.h>
int
main ()
{
-return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
+int (*fp) (FILE *, off_t, int) = fseeko;
+ return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
;
return 0;
}
@@ -12995,11 +12997,13 @@ cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#define _LARGEFILE_SOURCE 1
-#include <stdio.h>
+#include <sys/types.h> /* for off_t */
+ #include <stdio.h>
int
main ()
{
-return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
+int (*fp) (FILE *, off_t, int) = fseeko;
+ return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
;
return 0;
}
@@ -15291,8 +15295,7 @@ done
-
-for ac_func in 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
+for ac_func in 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
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_func" >&5
diff --git a/configure.ac b/configure.ac
index 29379d314..30bcd9db2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -327,7 +327,7 @@ AC_FUNC_STRNLEN
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])
diff --git a/doc/CODING-GUIDELINES b/doc/CODING-GUIDELINES
index 985df6846..ed320368b 100644
--- a/doc/CODING-GUIDELINES
+++ b/doc/CODING-GUIDELINES
@@ -382,6 +382,12 @@ processor operations, unlike ast_copy_string().
* 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.
diff --git a/include/asterisk.h b/include/asterisk.h
index f55d5bb0d..7ae81136b 100644
--- a/include/asterisk.h
+++ b/include/asterisk.h
@@ -178,4 +178,7 @@ struct ast_module;
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 */
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index acc96f735..3417c738e 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -126,9 +126,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
diff --git a/main/astobj2.c b/main/astobj2.c
index b80c407d0..2e9070d6d 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -262,7 +262,7 @@ static int __ao2_ref(void *user_data, const int delta)
/* 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);
}
diff --git a/main/cli.c b/main/cli.c
index 784628226..0b8120617 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -1426,7 +1426,7 @@ static int __ast_cli_unregister(struct ast_cli_entry *e, struct ast_cli_entry *e
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 @@ static int __ast_cli_register(struct ast_cli_entry *e, struct ast_cli_entry *ed)
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);
diff --git a/main/config.c b/main/config.c
index 870aaed57..5ea68a7a7 100644
--- a/main/config.c
+++ b/main/config.c
@@ -2340,7 +2340,7 @@ int ast_parse_arg(const char *arg, enum ast_parse_flags flags,
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, ":");
diff --git a/main/pbx.c b/main/pbx.c
index 4fff74b10..c428b0843 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -1728,7 +1728,7 @@ static int ext_cmp1(const char **p)
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]);
diff --git a/main/rtp.c b/main/rtp.c
index a05603f22..82610484a 100644
--- a/main/rtp.c
+++ b/main/rtp.c
@@ -675,7 +675,7 @@ int ast_stun_request(int s, struct sockaddr_in *dst,
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.
@@ -687,7 +687,7 @@ int ast_stun_request(int s, struct sockaddr_in *dst,
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 */
diff --git a/main/translate.c b/main/translate.c
index 96d67bc92..dfd50fcc5 100644
--- a/main/translate.c
+++ b/main/translate.c
@@ -451,7 +451,7 @@ static void rebuild_matrix(int samples)
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) {
diff --git a/utils/extconf.c b/utils/extconf.c
index 4353ba7be..78b911339 100644
--- a/utils/extconf.c
+++ b/utils/extconf.c
@@ -4406,7 +4406,7 @@ static int ext_cmp1(const char **p)
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]);