From 9f08cd5ec406b37e2f6517759f49e478be8f750e Mon Sep 17 00:00:00 2001 From: Martin Reinecke Date: Mon, 29 Oct 2012 10:48:18 +0100 Subject: [PATCH] improve comments and avoid warnings --- c_utils/memusage.c | 7 ++++--- libsharp/sharp.c | 7 +++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/c_utils/memusage.c b/c_utils/memusage.c index 20bf0a2..a1c25c0 100644 --- a/c_utils/memusage.c +++ b/c_utils/memusage.c @@ -38,7 +38,8 @@ double residentSetSize(void) FILE *statm = fopen("/proc/self/statm","r"); double res; if (!statm) return -1.0; - fscanf(statm,"%*f %lf",&res); + if (fscanf(statm,"%*f %lf",&res)) + { fclose(statm); return -1.0; } fclose(statm); return (res*4096); } @@ -55,8 +56,8 @@ double VmHWM(void) { fclose(f); return -1.0; } if (!strncmp(word, "VmHWM:", 6)) { - fscanf(f,"%lf",&res); - fscanf(f,"%2s",word); + if (fscanf(f,"%lf%2s",&res,word)<0) + { fclose(f); return -1.0; } if (strncmp(word, "kB", 2)) { fclose(f); return -1.0; } res *=1024; diff --git a/libsharp/sharp.c b/libsharp/sharp.c index c089ecb..69a4bfa 100644 --- a/libsharp/sharp.c +++ b/libsharp/sharp.c @@ -213,6 +213,9 @@ void sharp_destroy_geom_info (sharp_geom_info *geom_info) DEALLOC (geom_info); } +/* This currently requires all m values from 0 to nm-1 to be present. + It might be worthwhile to relax this criterion such that holes in the m + distribution are permissible. */ static int sharp_get_mmax (int *mval, int nm) { int *mcheck=RALLOC(int,nm); @@ -220,12 +223,12 @@ static int sharp_get_mmax (int *mval, int nm) for (int i=0; i=0) && (m_cur=0) && (m_cur