search for: strlen

Displaying 20 results from an estimated 2731 matches for "strlen".

2013 Sep 05
16
[PATCH] minios: Fix xenbus_rm() calls in frontend drivers
...ertions(+), 44 deletions(-) diff --git a/extras/mini-os/blkfront.c b/extras/mini-os/blkfront.c index f4283a9..ab58102 100644 --- a/extras/mini-os/blkfront.c +++ b/extras/mini-os/blkfront.c @@ -254,7 +254,7 @@ void shutdown_blkfront(struct blkfront_dev *dev) XenbusState state; char path[strlen(dev->backend) + 1 + 5 + 1]; - char nodename[strlen(dev->nodename) + 1 + 5 + 1]; + char nodename[strlen(dev->nodename) + 1 + 13 + 1]; blkfront_sync(dev); @@ -289,7 +289,6 @@ void shutdown_blkfront(struct blkfront_dev *dev) XenbusStateInitialising, err);...
2007 Sep 07
1
"bug" and patch: quadratic running time for strsplit(..., fixed=TRUE) (PR#9902)
...77 msec i=10000 time= 230 msec i=11000 time= 275 msec i=12000 time= 308 msec i=13000 time= 371 msec i=14000 time= 446 msec i=15000 time= 544 msec i=16000 time= 639 msec i=17000 time= 726 msec i=18000 time= 864 msec i=19000 time= 944 msec i=20000 time= 1106 msec DIAGNOSIS strsplit() uses strlen() in the bounds check clause of a for(;;) statement, which forces a full scan of the source string for each character in the source string. Unlike R's LENGTH() macro, strlen for C strings is an expensive operation, and in this case (at least), gcc 4.0.3's -O2 level optimizer is not able to...
2010 May 06
3
Possible bug in chan_sip:add_sdp
Am I missing something here? I see if (needvideo) { /* only if video response is appropriate */ add_line(resp, m_video->str); add_line(resp, a_video->str); add_line(resp, hold); /* Repeat hold for the video stream */ } else if (p->offered_media[SDP_VIDEO].offered) { snprintf(dummy_answer,
2018 Apr 20
2
Missed strlen optimizations
Hello, Code: https://godbolt.org/g/EG4Wi6 unsigned fff3(void) { char buf[10] = ""; return strlen(buf); } Since we are memset-ing before strlen call, we could replace strlen with just 0. Has LLVM any API to get "last instruction before strlen" which modifies strlen argument "buf"? So we can check "yes, it is memset there, replace strlen with zero" ? Thanks ----...
2018 Apr 20
2
Missed strlen optimizations
...at gmail.com>: > Is: > > > 2018-04-20 18:07 GMT+02:00 Dávid Bolvanský <david.bolvansky at gmail.com>: > >> Hello, >> >> Code: https://godbolt.org/g/EG4Wi6 >> >> unsigned fff3(void) { >> char buf[10] = ""; >> return strlen(buf); >> } >> >> Since we are memset-ing before strlen call, we could replace strlen with >> just 0. >> >> Has LLVM any API to get "last instruction before strlen" which modifies >> strlen argument "buf"? So we can check "yes, it is...
2002 Feb 06
2
SFTP Status Bar..
...rlength; + progressbar = xrealloc(progressbar, barlength); + memset(progressbar, '*', barlength); + } + + snprintf(buf, sizeof(buf), "\r%-20.20s %3d%% ", + (filename?filename:""), ratio); + if (barlength > 0) { + i = barlength * ratio / 100; + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), + "|%.*s%*s|", i, progressbar, barlength - i, ""); + } + i = 0; + abbrevsize = cursize; + while (abbrevsize >= 100000 && i < sizeof(prefixes)) { + i++; + abbrevsize >>= 10; + } + snprintf(buf + strlen(buf), sizeof(buf) -...
2018 Apr 20
0
Missed strlen optimizations
Is: 2018-04-20 18:07 GMT+02:00 Dávid Bolvanský <david.bolvansky at gmail.com>: > Hello, > > Code: https://godbolt.org/g/EG4Wi6 > > unsigned fff3(void) { > char buf[10] = ""; > return strlen(buf); > } > > Since we are memset-ing before strlen call, we could replace strlen with > just 0. > > Has LLVM any API to get "last instruction before strlen" which modifies > strlen argument "buf"? So we can check "yes, it is memset there, replace >...
2018 Apr 20
0
Missed strlen optimizations
...; >> 2018-04-20 18:07 GMT+02:00 Dávid Bolvanský <david.bolvansky at gmail.com>: >> >>> Hello, >>> >>> Code: https://godbolt.org/g/EG4Wi6 >>> >>> unsigned fff3(void) { >>> char buf[10] = ""; >>> return strlen(buf); >>> } >>> >>> Since we are memset-ing before strlen call, we could replace strlen with >>> just 0. >>> >>> Has LLVM any API to get "last instruction before strlen" which modifies >>> strlen argument "buf"? So w...
2004 Aug 31
1
[PATCH] supporting a remote scp path option in scp
...getshouldbedirectory = 1; + rscpcmdlen += 3; break; case 'f': /* "from" */ iamremote = 1; @@ -316,8 +327,11 @@ remin = remout = -1; do_cmd_pid = -1; + rscpcmdlen += strlen(scp_remote_program); + rscpcmd = xmalloc(rscpcmdlen); /* Command to be executed on remote system using "ssh". */ - (void) snprintf(cmd, sizeof cmd, "scp%s%s%s%s", + (void) snprintf(rscpcmd, rscpcmdlen, "%s%s%s%s%s", + scp_remote_pr...
2007 Mar 24
2
Subtle bug in do_basename
Hello, I've been wondering why my no-optimization R-devel builds have been hanging during "building/updating package indices ...". I tracked it down with gdb to this line from do_basename in utils.c: while ( *(p = buf + strlen(buf) - 1) == fsp ) *p = '\0'; Now, imagine if your compiler places the variable fsp immediately before buf on the stack, and strlen(buf) is 0. Yup, you get an infinite loop because p will always be assigned the address of fsp. I'm not quite sure what happens when the stack variables...
2002 Jan 30
1
Quick sftp status indicator.
...ratio); + + barlength = getttywidth() - 51; + if (barlength > progressbar_size) { + progressbar_size = barlength; + progressbar = xrealloc(progressbar, barlength); + memset(progressbar, '*', barlength); + } + + if (barlength > 0) { + i = barlength * ratio / 100; + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), + "|%.*s%*s|", i, progressbar, barlength - i, ""); + } + i = 0; + abbrevsize = cursize; + while (abbrevsize >= 100000 && i < sizeof(prefixes)) { + i++; + abbrevsize >>= 10; + } + snprintf(buf + strlen(buf), sizeof(buf) -...
2002 Nov 25
0
Linux and Samba Code
...locations of the standard Unix and SMB password programs * in the "#defines" near the top (do NOT be tempted to add code to make * these changeable from command-line arguments: these programs will * be run as root!). If your paths are obscenely long, examine the * size of STRLEN to make sure it will accomodate them. * The only check on password quality is existence (len > 0) and for * non-root callers a minimum length (MINPWLEN). This can be enhanced. * The sleep()s in the actual pwd-changing routines appeared to be necessary * in some early tests I did wi...
2002 Feb 02
0
Version two of progressbar for scp/sftp
...ratio); + + barlength = getttywidth() - 51; + if (barlength > progressbar_size) { + progressbar_size = barlength; + progressbar = xrealloc(progressbar, barlength); + memset(progressbar, '*', barlength); + } + + if (barlength > 0) { + i = barlength * ratio / 100; + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), + "|%.*s%*s|", i, progressbar, barlength - i, ""); + } + i = 0; + abbrevsize = cursize; + while (abbrevsize >= 100000 && i < sizeof(prefixes)) { + i++; + abbrevsize >>= 10; + } + snprintf(buf + strlen(buf), sizeof(buf) -...
2000 Dec 12
1
scp and filenames with weird characters
...100% |*****************************************| 0 --:-- ETA Although the simplest is to patch the sourcecode: (A patchfile for the CVS-version is included, but these fixes should work for any 2.2.0-version (as the one in Debian woody) as far as I can see) in scp.c: - strlen(thost) + strlen(targ) + CMDNEEDS + 32; + strlen(thost) + strlen(targ) + CMDNEEDS + 40; - "%s%s -x -o'FallBackToRsh no' -n -l %s %s %s %s '%s%s%s:%s'", + "%s%s -x -o'FallBackToRsh no' -n -l \"%s\" \"%s\" \"%s\"...
2006 Nov 02
0
ssh strlen fixes
...ray/openbsd/src/usr.bin/ssh/misc.c,v retrieving revision 1.64 diff -u -p -r1.64 misc.c --- misc.c 3 Aug 2006 03:34:42 -0000 1.64 +++ misc.c 2 Nov 2006 20:05:41 -0000 @@ -604,11 +604,15 @@ read_keyfile_line(FILE *f, const char *f { while (fgets(buf, bufsz, f) != NULL) { (*lineno)++; - if (buf[strlen(buf) - 1] == '\n' || feof(f)) { + if (buf[0] != '\0' && buf[strlen(buf) - 1] == '\n' || feof(f)) { return 0; } else { - debug("%s: %s line %lu exceeds size limit", __func__, - filename, *lineno); + if (buf[0] != '\0') + debug(&q...
2012 Jan 23
2
[LLVMdev] Possible bug in the dragonegg
Hi Duncan, >> #include<stdio.h> >> #include<string.h> >> >> int main(int argc, char** argv){ >> >> char a[8] = "aaaaaaa"; >> char b[8] = "bbbbbbb"; >> >> char *c = (char*) malloc(sizeof(char)*(strlen(a)+strlen(b)+1)); >> memcpy(c, a, strlen(a)); >> memcpy(c + strlen(a), b, strlen(b) + 1); >> >> printf("a = %s, b = %s, c = %s\n", a, b, c); >> } >> * >> and compiling and executing in the following way: >> >> $> gcc -fplugin=~/dra...
2012 Jan 19
4
[LLVMdev] What happened to "malloc" in LLVM 3.0 IR?
...i32 0), double %_castInttoDbl) ; <i8*> [#uses=2] %_castInttoDbl4 = sitofp i32 %taille to double ; <double> [#uses=1] %1 = call i8* @lista_sprintf(i8* getelementptr inbounds ([5 x i8]* @_stringexpr3, i32 0, i32 0), double %_castInttoDbl4) ; <i8*> [#uses=2] %_lenL = call i32 @strlen(i8* getelementptr inbounds ([2 x i8]* @_stringexpr4, i32 0, i32 0)) ; <i32> [#uses=1] %_lenR = call i32 @strlen(i8* %1) ; <i32> [#uses=1] %_totallen = add i32 %_lenL, 1 ; <i32> [#uses=1] %2 = add i32 %_totallen, %_lenR ; <i32...
2017 Apr 26
1
Function LICM for readonly, nocapture functions
Hey all, I was doing some investigation of LICM and I ran into something that seems a bit odd to me. Suppose I was looking at the following code snippet: #define N 1000 int main() { int B[N]; char A[N]; for(int i=0; i<N; i++) { B[i] = strlen(A); } return B[0]+B[N-1]; } Among other optimizations that I may want to happen, I'd hope that the call to strlen could be moved outside the loop via LICM. Unfortunately, this is not the case. Looking at the IR I found the following. The function strlen is marked readonly and the argum...
2016 Jan 19
6
FWD: [patch] scp + UTF-8
...buf_size < (int) sizeof(buf) - 35; buf_width++) + buf[buf_size++] = ' '; + buf[buf_size] = '\0'; } /* percent of transfer done */ @@ -174,18 +195,18 @@ refresh_progress_meter(void) percent = ((float)cur_pos / end_pos) * 100; else percent = 100; - snprintf(buf + strlen(buf), win_size - strlen(buf), + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %3d%% ", percent); /* amount transferred */ - format_size(buf + strlen(buf), win_size - strlen(buf), + format_size(buf + strlen(buf), sizeof(buf) - strlen(buf), cur_pos); - strlcat(buf...
2012 Apr 05
3
[PATCH] Fix buffer overflow in metaflac
strlen() returns the length excluding the terminating null byte..then an string of len 4 will be off-by-one in application_id[4]; GCC 4.7 detects this bug. --- src/metaflac/options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/metaflac/options.c b/src/metaflac/options.c in...