diff options
author | Guillem Jover <guillem@debian.org> | 2011-03-13 04:25:02 +0100 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2011-03-14 07:21:55 +0100 |
commit | c0f00ddf9a3258d28aa3ad306adabc3eb34476d9 (patch) | |
tree | 969e543088ea25bc6ed9ddf468812060cee962af /dselect | |
parent | 6761f32a6b9476cd63f874e8fbbb9346068049c3 (diff) | |
download | dpkg-c0f00ddf9a3258d28aa3ad306adabc3eb34476d9.tar.gz |
dselect: Use m_asprintf() instead of ad-hoc string construction
Diffstat (limited to 'dselect')
-rw-r--r-- | dselect/method.cc | 10 | ||||
-rw-r--r-- | dselect/methparse.cc | 9 |
2 files changed, 5 insertions, 14 deletions
diff --git a/dselect/method.cc b/dselect/method.cc index 4d02890e1..f0e2fe7af 100644 --- a/dselect/method.cc +++ b/dselect/method.cc @@ -105,13 +105,9 @@ static enum urqresult ensureoptions(void) { static enum urqresult lockmethod(void) { struct flock fl; - if (!methodlockfile) { - int l; - l= strlen(admindir); - methodlockfile= new char[l+sizeof(METHLOCKFILE)+2]; - strcpy(methodlockfile,admindir); - strcpy(methodlockfile+l, "/" METHLOCKFILE); - } + if (methodlockfile == NULL) + m_asprintf(&methodlockfile, "%s/%s", admindir, METHLOCKFILE); + if (methlockfd == -1) { methlockfd= open(methodlockfile, O_RDWR|O_CREAT|O_TRUNC, 0660); if (methlockfd == -1) { diff --git a/dselect/methparse.cc b/dselect/methparse.cc index c8fd7c408..00a304c01 100644 --- a/dselect/methparse.cc +++ b/dselect/methparse.cc @@ -235,15 +235,10 @@ void getcurrentopt() { char methoptbuf[IMETHODMAXLEN+1+IOPTIONMAXLEN+2]; FILE *cmo; int l; - int admindirlen; char *p; - if (!methoptfile) { - admindirlen= strlen(admindir); - methoptfile= new char[admindirlen + sizeof(CMETHOPTFILE) + 2]; - strcpy(methoptfile,admindir); - strcpy(methoptfile+admindirlen, "/" CMETHOPTFILE); - } + if (methoptfile == NULL) + m_asprintf(&methoptfile, "%s/%s", admindir, CMETHOPTFILE); coption= 0; cmo= fopen(methoptfile,"r"); |