[pacman-dev] [PATCH 0/3] Code and docs enhancements
Some small code and documentation enhancements. Barbu Paul - Gheorghe (3): fixed coding standard violation fixed typo added coding standard HACKING | 44 ++++++++++++++++++++++++++++++++++++++++++++ lib/libalpm/db.c | 7 ++++++- test/pacman/README | 2 +- 3 files changed, 51 insertions(+), 2 deletions(-) -- Barbu Paul - Gheorghe Common sense is not so common - Voltaire Visit My GitHub profile to see my open-source projects - https://github.com/paullik
Signed-off-by: Barbu Paul - Gheorghe <barbu.paul.gheorghe@gmail.com> --- lib/libalpm/db.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index bf9c3f0..63d18be 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -136,8 +136,13 @@ alpm_list_t SYMEXPORT *alpm_db_get_servers(const alpm_db_t *db) int SYMEXPORT alpm_db_set_servers(alpm_db_t *db, alpm_list_t *servers) { ASSERT(db != NULL, return -1); - if(db->servers) FREELIST(db->servers); + + if(db->servers){ + FREELIST(db->servers); + } + db->servers = servers; + return 0; } -- Barbu Paul - Gheorghe Common sense is not so common - Voltaire Visit My GitHub profile to see my open-source projects - https://github.com/paullik
On Tue, Jul 31, 2012 at 09:24:29PM +0300, Barbu Paul - Gheorghe wrote:
Signed-off-by: Barbu Paul - Gheorghe <barbu.paul.gheorghe@gmail.com> --- lib/libalpm/db.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index bf9c3f0..63d18be 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -136,8 +136,13 @@ alpm_list_t SYMEXPORT *alpm_db_get_servers(const alpm_db_t *db) int SYMEXPORT alpm_db_set_servers(alpm_db_t *db, alpm_list_t *servers) { ASSERT(db != NULL, return -1); - if(db->servers) FREELIST(db->servers); + + if(db->servers){
This in itself violates the standards. Space between the closing paren and opening brace. Personally, I would have just discarded the if, since the functions that FREELIST calls are all NULL safe.
+ FREELIST(db->servers); + } + db->servers = servers; + return 0; }
-- Barbu Paul - Gheorghe Common sense is not so common - Voltaire Visit My GitHub profile to see my open-source projects - https://github.com/paullik
Signed-off-by: Barbu Paul - Gheorghe <barbu.paul.gheorghe@gmail.com> --- lib/libalpm/db.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index bf9c3f0..4520fe1 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -136,7 +136,7 @@ alpm_list_t SYMEXPORT *alpm_db_get_servers(const alpm_db_t *db) int SYMEXPORT alpm_db_set_servers(alpm_db_t *db, alpm_list_t *servers) { ASSERT(db != NULL, return -1); - if(db->servers) FREELIST(db->servers); + FREELIST(db->servers); db->servers = servers; return 0; } -- Barbu Paul - Gheorghe Common sense is not so common - Voltaire Visit My GitHub profile to see my open-source projects - https://github.com/paullik
Signed-off-by: Barbu Paul - Gheorghe <barbu.paul.gheorghe@gmail.com> --- test/pacman/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/pacman/README b/test/pacman/README index ae3303a..e563379 100644 --- a/test/pacman/README +++ b/test/pacman/README @@ -183,7 +183,7 @@ Examples: Note: there is no need to explicitly create a database. The "local" one already exists (even if empty), and sync databases are created on the fly when -a new database new is given. +a new database name is given. * addpkg(package) -- Barbu Paul - Gheorghe Common sense is not so common - Voltaire Visit My GitHub profile to see my open-source projects - https://github.com/paullik
Signed-off-by: Barbu Paul - Gheorghe <barbu.paul.gheorghe@gmail.com> --- HACKING | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/HACKING b/HACKING index 8a59344..e859bd8 100644 --- a/HACKING +++ b/HACKING @@ -101,6 +101,50 @@ alpm_list_t *alpm_list_add(alpm_list_t *list, void *data) NOT for(a=0;a<n&&n>0;a++,n--) {} +9. Declare all variables at the start of the block. +[source,C] +------------------------------------------- +int SYMEXPORT alpm_db_remove_server(alpm_db_t *db, const char *url) +{ + char *newurl, *vdata = NULL; + + newurl = url; + if(!newurl) { + return -1; + } + + ... + + if(vdata) { + ... + } + + return 1; +} +------------------------------------------- + + NOT + +[source,C] +------------------------------------------- +int SYMEXPORT alpm_db_remove_server(alpm_db_t *db, const char *url) +{ + char *newurl = url; + + if(!newurl) { + return -1; + } + + char *vdata = NULL; + + if(vdata) { + ... + } + + return 1; +} +------------------------------------------- + Other Concerns -------------- -- Barbu Paul - Gheorghe Common sense is not so common - Voltaire Visit My GitHub profile to see my open-source projects - https://github.com/paullik
participants (2)
-
Barbu Paul - Gheorghe
-
Dave Reisner