FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 01-09-2012, 05:09 PM
jjacky
 
Default only create string when needed

the entry's name is only used when not "." or ".." so
only print the string then. (i'm guessing enormous
speed improvements right there... )

Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com>
---
src/pacman/util.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/pacman/util.c b/src/pacman/util.c
index 467bedf..2d88bac 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -191,9 +191,9 @@ int rmrf(const char *path)
}
for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
if(dp->d_ino) {
- char name[PATH_MAX];
- sprintf(name, "%s/%s", path, dp->d_name);
if(strcmp(dp->d_name, "..") != 0 &&
strcmp(dp->d_name, ".") != 0) {

+ char name[PATH_MAX];
+ snprintf(name, PATH_MAX,
"%s/%s", path, dp->d_name);

errflag += rmrf(name);
}
}
--
1.7.8.3
 
Old 01-09-2012, 05:44 PM
Dan McGee
 
Default only create string when needed

On Mon, Jan 9, 2012 at 12:09 PM, jjacky <i.am.jack.mail@gmail.com> wrote:
> the entry's name is only used when not "." or ".." so
> only print the string then. (i'm guessing enormous
> speed improvements right there... )
>
> Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com>
> ---

Looks good to me, however, can you fix the one in lib/libalpm/util.c
as well please?

(I would also prefer you use proper capitalization and punctuation in
your commit messages, thanks!)

> *src/pacman/util.c | * *4 ++--
> *1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/pacman/util.c b/src/pacman/util.c
> index 467bedf..2d88bac 100644
> --- a/src/pacman/util.c
> +++ b/src/pacman/util.c
> @@ -191,9 +191,9 @@ int rmrf(const char *path)
> * * * * * * * *}
> * * * * * * * *for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
> * * * * * * * * * * * *if(dp->d_ino) {
> - * * * * * * * * * * * * * * * char name[PATH_MAX];
> - * * * * * * * * * * * * * * * sprintf(name, "%s/%s", path, dp->d_name);
> * * * * * * * * * * * * * * * *if(strcmp(dp->d_name, "..") != 0 &&
> strcmp(dp->d_name, ".") != 0) {
> + * * * * * * * * * * * * * * * * * * * char name[PATH_MAX];
> + * * * * * * * * * * * * * * * * * * * snprintf(name, PATH_MAX, "%s/%s",
> path, dp->d_name);
> * * * * * * * * * * * * * * * * * * * *errflag += rmrf(name);
> * * * * * * * * * * * * * * * *}
> * * * * * * * * * * * *}
> --
> 1.7.8.3
>
 
Old 01-09-2012, 07:02 PM
Dan McGee
 
Default only create string when needed

On Mon, Jan 9, 2012 at 12:09 PM, jjacky <i.am.jack.mail@gmail.com> wrote:
> the entry's name is only used when not "." or ".." so
> only print the string then. (i'm guessing enormous
> speed improvements right there... )
>
> Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com>
> ---

$ git am -3 -s < /tmp/rmrf-libalpm.patch
Applying: Only create string when needed (libalpm)
fatal: corrupt patch at line 12
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Patch failed at 0001 Only create string when needed (libalpm)

I can't apply this or the other one, because you've gummed up all the
formatting. If you aren't using git-send-email, you probably should
be, as all tabs got converted to spaces. Please resend your patches
correctly, thanks!

-Dan
 

Thread Tools




All times are GMT. The time now is 04:33 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org