Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing warnings in conda build. #121

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 18 additions & 14 deletions numcosmo/math/ncm_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ G_END_DECLS
#define _NCM_MATRIX_INLINE_H_
#ifdef NUMCOSMO_HAVE_INLINE
#ifndef __GTK_DOC_IGNORE__
#ifndef NUMCOSMO_GIR_SCAN

G_BEGIN_DECLS

Expand Down Expand Up @@ -257,15 +258,15 @@ NCM_INLINE void
ncm_matrix_addto (NcmMatrix *cm, guint i, guint j, gdouble val)
{
gdouble *m = gsl_matrix_ptr (ncm_matrix_gsl (cm), i, j);

*m += val;
}

NCM_INLINE void
ncm_matrix_transpose (NcmMatrix *cm)
{
const gint ret = gsl_matrix_transpose (ncm_matrix_gsl (cm));

NCM_TEST_GSL_RESULT ("gsl_matrix_transpose", ret);
}

Expand Down Expand Up @@ -336,7 +337,7 @@ ncm_matrix_mul_row (NcmMatrix *cm, const guint row_i, const gdouble val)
{
const guint ncols = ncm_matrix_ncols (cm);
guint i;

for (i = 0; i < ncols; i++)
{
ncm_matrix_ptr (cm, row_i, i)[0] *= val;
Expand All @@ -348,7 +349,7 @@ ncm_matrix_mul_col (NcmMatrix *cm, const guint col_i, const gdouble val)
{
const guint nrows = ncm_matrix_nrows (cm);
guint i;

for (i = 0; i < nrows; i++)
{
ncm_matrix_ptr (cm, i, col_i)[0] *= val;
Expand All @@ -362,9 +363,9 @@ ncm_matrix_get_diag (NcmMatrix *cm, NcmVector *diag)
const guint ncols = ncm_matrix_ncols (cm);
const guint n = MIN (nrows, ncols);
guint i;

g_assert_cmpuint (ncm_vector_len (diag), >=, n);

for (i = 0; i < n; i++)
{
ncm_vector_set (diag, i, ncm_matrix_get (cm, i, i));
Expand All @@ -378,9 +379,9 @@ ncm_matrix_set_diag (NcmMatrix *cm, NcmVector *diag)
const guint ncols = ncm_matrix_ncols (cm);
const guint n = MIN (nrows, ncols);
guint i;

g_assert_cmpuint (ncm_vector_len (diag), >=, n);

for (i = 0; i < n; i++)
{
ncm_matrix_set (cm, i, i, ncm_vector_get (diag, i));
Expand Down Expand Up @@ -417,13 +418,14 @@ ncm_matrix_memcpy_to_colmajor (NcmMatrix *cm1, const NcmMatrix *cm2)
const guint nrows = ncm_matrix_nrows (cm1);
const guint ncols = ncm_matrix_ncols (cm1);
register guint i;

g_assert_cmpuint (nrows, ==, ncm_matrix_nrows (cm2));
g_assert_cmpuint (ncols, ==, ncm_matrix_ncols (cm2));

for (i = 0; i < nrows; i++)
{
register guint j;

for (j = 0; j < ncols; j++)
{
ncm_matrix_set_colmajor (cm1, i, j, ncm_matrix_get (cm2, i, j));
Expand All @@ -435,23 +437,23 @@ NCM_INLINE void
ncm_matrix_set_col (NcmMatrix *cm, const guint n, const NcmVector *cv)
{
gint ret = gsl_matrix_set_col (ncm_matrix_gsl (cm), n, ncm_vector_const_gsl (cv));

g_assert (ret == GSL_SUCCESS);
}

NCM_INLINE void
ncm_matrix_set_row (NcmMatrix *cm, const guint n, const NcmVector *cv)
{
gint ret = gsl_matrix_set_row (ncm_matrix_gsl (cm), n, ncm_vector_const_gsl (cv));

g_assert (ret == GSL_SUCCESS);
}

NCM_INLINE GArray *
ncm_matrix_get_array (NcmMatrix *cm)
{
g_assert (cm->type == NCM_MATRIX_GARRAY);

return g_array_ref (cm->pdata);
}

Expand All @@ -461,14 +463,15 @@ ncm_matrix_dup_array (NcmMatrix *cm)
const guint nrows = ncm_matrix_nrows (cm);
const guint ncols = ncm_matrix_ncols (cm);
const guint total = nrows * ncols;
GArray *a = g_array_sized_new (FALSE, FALSE, sizeof (gdouble), total);
GArray *a = g_array_sized_new (FALSE, FALSE, sizeof (gdouble), total);
register guint i;
register guint j;
register guint k;

g_array_set_size (a, total);

k = 0;

for (i = 0; i < nrows; i++)
for (j = 0; j < ncols; j++)
g_array_index (a, gdouble, k++) = ncm_matrix_get (cm, i, j);
Expand Down Expand Up @@ -552,6 +555,7 @@ ncm_matrix_const_data (const NcmMatrix *cm)

G_END_DECLS

#endif /* NUMCOSMO_GIR_SCAN */
#endif /* __GTK_DOC_IGNORE__ */
#endif /* NUMCOSMO_HAVE_INLINE */
#endif /* _NCM_MATRIX_INLINE_H_ */
Expand Down
2 changes: 2 additions & 0 deletions numcosmo/math/ncm_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ G_END_DECLS
#define _NCM_VECTOR_INLINE_H_
#ifdef NUMCOSMO_HAVE_INLINE
#ifndef __GTK_DOC_IGNORE__
#ifndef NUMCOSMO_GIR_SCAN

G_BEGIN_DECLS

Expand Down Expand Up @@ -598,6 +599,7 @@ ncm_vector_between (const NcmVector *cv, const NcmVector *cv_lb, const NcmVector

G_END_DECLS

#endif /* NUMCOSMO_GIR_SCAN */
#endif /* __GTK_DOC_IGNORE__ */
#endif /* NUMCOSMO_HAVE_INLINE */
#endif /* _NCM_VECTOR_INLINE_H_ */
Expand Down
8 changes: 6 additions & 2 deletions numcosmo/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,8 @@ if enable_gir
'numcosmo-math.h',
]

# -U__OPTIMIZE__ is needed to avoid a bug in gobject-introspection
# It has no effect on the generated code
numcosmo_math_gir = gnome.generate_gir(
libnumcosmo,
namespace: 'NumCosmoMath',
Expand All @@ -786,7 +788,7 @@ if enable_gir
dependencies: libnumcosmo_dep,
includes: 'GObject-2.0',
install: true,
extra_args: ['-DNUMCOSMO_GIR_SCAN'],
extra_args: ['-DNUMCOSMO_GIR_SCAN', '-U__OPTIMIZE__'],
)

nc_introspection_sources = [
Expand All @@ -797,6 +799,8 @@ if enable_gir
'numcosmo.h',
]

# -U__OPTIMIZE__ is needed to avoid a bug in gobject-introspection
# It has no effect on the generated code
numcosmo_gir = gnome.generate_gir(
libnumcosmo,
namespace: 'NumCosmo',
Expand All @@ -808,7 +812,7 @@ if enable_gir
dependencies: libnumcosmo_dep,
includes: ['GObject-2.0', numcosmo_math_gir[0]],
install: true,
extra_args: ['-DNUMCOSMO_GIR_SCAN'],
extra_args: ['-DNUMCOSMO_GIR_SCAN', '-U__OPTIMIZE__'],
)
if have_vala
vapi_deps = [
Expand Down
6 changes: 5 additions & 1 deletion numcosmo/plc/cldf/cldf.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,11 @@ char* cldf_readstr(cldf *df, char *key, int *sz,error **err) {
res = malloc_err(size+1,err);
forwardError(*err,__LINE__,NULL);
f = fopen_err(pth,"r",err);
fread(res, 1, size, f);
if (fread(res, 1, size, f) != size)
{
fprintf(stderr, "Error reading file.\n");
exit (1);
}
res[size] = '\0';
fclose(f);
if (nsz<0 && sz !=NULL) {
Expand Down