diff options
| author | Eli Zaretskii | 2015-11-30 22:46:45 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2015-11-30 22:46:45 +0200 |
| commit | ec62f2f5ad37ff5fc7ba77f57e2fc81ac7cdcc9d (patch) | |
| tree | a1c1648d37ca51cd9312c0a0978189db65f48ce2 /src/emacs-module.c | |
| parent | f227655b2d059564b55954b73a4a5c1e6eb0190a (diff) | |
| download | emacs-ec62f2f5ad37ff5fc7ba77f57e2fc81ac7cdcc9d.tar.gz emacs-ec62f2f5ad37ff5fc7ba77f57e2fc81ac7cdcc9d.zip | |
Fix last change
* src/emacs-module.c (lisp_to_value, value_to_lisp)
[WIDE_EMACS_INT]: Avoid compiler warnings.
Diffstat (limited to 'src/emacs-module.c')
| -rw-r--r-- | src/emacs-module.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c index 69649b236a1..67e5eab0110 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -850,15 +850,15 @@ static Lisp_Object | |||
| 850 | value_to_lisp (emacs_value v) | 850 | value_to_lisp (emacs_value v) |
| 851 | { | 851 | { |
| 852 | #ifdef WIDE_EMACS_INT | 852 | #ifdef WIDE_EMACS_INT |
| 853 | EMACS_INT tmp = (EMACS_INT)v; | 853 | ptrdiff_t tmp = (ptrdiff_t)v; |
| 854 | int tag = tmp & ((1 << GCTYPEBITS) - 1); | 854 | int tag = tmp & ((1 << GCTYPEBITS) - 1); |
| 855 | Lisp_Object o; | 855 | Lisp_Object o; |
| 856 | switch (tag) | 856 | switch (tag) |
| 857 | { | 857 | { |
| 858 | case_Lisp_Int: | 858 | case_Lisp_Int: |
| 859 | o = make_lisp_ptr ((tmp - tag) >> GCTYPEBITS, tag); break; | 859 | o = make_lisp_ptr ((void *)((tmp - tag) >> GCTYPEBITS), tag); break; |
| 860 | default: | 860 | default: |
| 861 | o = make_lisp_ptr ((void*)(tmp - tag), tag); | 861 | o = make_lisp_ptr ((void *)(tmp - tag), tag); |
| 862 | } | 862 | } |
| 863 | /* eassert (lisp_to_value (o) == v); */ | 863 | /* eassert (lisp_to_value (o) == v); */ |
| 864 | if (CONSP (o) && EQ (XCDR (o), ltv_mark)) | 864 | if (CONSP (o) && EQ (XCDR (o), ltv_mark)) |
| @@ -892,9 +892,10 @@ lisp_to_value (Lisp_Object o) | |||
| 892 | case_Lisp_Int: | 892 | case_Lisp_Int: |
| 893 | { | 893 | { |
| 894 | EMACS_UINT val = i & VALMASK; | 894 | EMACS_UINT val = i & VALMASK; |
| 895 | if (val == (EMACS_UINT)(emacs_value)val) | 895 | if (val <= (SIZE_MAX >> GCTYPEBITS)) |
| 896 | { | 896 | { |
| 897 | emacs_value v = (emacs_value) ((val << GCTYPEBITS) | tag); | 897 | size_t tv = (size_t)val; |
| 898 | emacs_value v = (emacs_value) ((tv << GCTYPEBITS) | tag); | ||
| 898 | eassert (EQ (value_to_lisp (v), o)); | 899 | eassert (EQ (value_to_lisp (v), o)); |
| 899 | return v; | 900 | return v; |
| 900 | } | 901 | } |
| @@ -904,13 +905,13 @@ lisp_to_value (Lisp_Object o) | |||
| 904 | default: | 905 | default: |
| 905 | { | 906 | { |
| 906 | void *ptr = XUNTAG (o, tag); | 907 | void *ptr = XUNTAG (o, tag); |
| 907 | if (((EMACS_UINT)ptr) & ((1 << GCTYPEBITS) - 1)) | 908 | if (((size_t)ptr) & ((1 << GCTYPEBITS) - 1)) |
| 908 | { /* Pointer is not properly aligned! */ | 909 | { /* Pointer is not properly aligned! */ |
| 909 | eassert (!CONSP (o)); /* Cons cells have to always be aligned! */ | 910 | eassert (!CONSP (o)); /* Cons cells have to always be aligned! */ |
| 910 | o = Fcons (o, ltv_mark); | 911 | o = Fcons (o, ltv_mark); |
| 911 | ptr = XUNTAG (o, tag); | 912 | ptr = XUNTAG (o, tag); |
| 912 | } | 913 | } |
| 913 | emacs_value v = (emacs_value)(((EMACS_UINT) ptr) | tag); | 914 | emacs_value v = (emacs_value)(((size_t) ptr) | tag); |
| 914 | eassert (EQ (value_to_lisp (v), o)); | 915 | eassert (EQ (value_to_lisp (v), o)); |
| 915 | return v; | 916 | return v; |
| 916 | } | 917 | } |