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/method.cc | |
parent | 6761f32a6b9476cd63f874e8fbbb9346068049c3 (diff) | |
download | dpkg-c0f00ddf9a3258d28aa3ad306adabc3eb34476d9.tar.gz |
dselect: Use m_asprintf() instead of ad-hoc string construction
Diffstat (limited to 'dselect/method.cc')
-rw-r--r-- | dselect/method.cc | 10 |
1 files changed, 3 insertions, 7 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) { |